user5702166
user5702166

Reputation:

How to extract some source code from DOM in PhantomJS?

I am trying to get certain data from a website, though it is not actual text, rather the actual class name of a div (that is where the data I want is stored).

 < td id="pdpStoreInventoryStatus_4336" class="store_stock_level out_of_stock">

So my question is how, in PhantomJS, would I go about retrieving this actual data?

Upvotes: 0

Views: 102

Answers (1)

Vaviloff
Vaviloff

Reputation: 16838

var page = require('webpage').create();
page.open('http://example.com/', function() {

    var className = page.evaluate(function(){
        return document.getElementById("id").className;
    });        

    console.log(className);
    phantom.exit();

});

Upvotes: 1

Related Questions