You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to navigagte using this package?
From a given URL, it should find out a link to another page and after loading that we should be able to scrape content from that. How can we do that here?
Here is the sample code which does not work. Can someone tell me why it doesn't work :
driver.create({ path: require('phantomjs').path }, function (err, browser) {
return browser.createPage(function (err, page) {
return page.open(matchurl, function (err,status) {
console.log("opened site? ", status);
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function (err) {
// jQuery Loaded.
// Wait for a bit for AJAX content to load on the page. Here, we are waiting 5 seconds.
setTimeout(function () {
return page.evaluate(function () {
//Get what you want from the page using jQuery. A good way is to populate an object with all the jQuery commands that you need and then return the object.
var inningsinfo = [];
var scoretable = [];
var recentovers = [];
var bowlingtable = [];
$('.innings-information').each(function () { inningsinfo.push($(this).html()); });
$('.score-table').each(function () { scoretable.push($(this).html()); });
$('.recent-overs').each(function () { recentovers.push($(this).html()); });
var nav = $('.tab-full-scorecard')[0]; // obtain reference to the underlying DOMElement
// click anchor link to "Modular code"
var ev = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
nav.dispatchEvent(ev);
$('.bowling-table').each(function () { bowlingtable.push($(this).html()); });
//console.log("inningsinfo",inningsinfo);
return{innings_info:inningsinfo,
score_table:scoretable,
recent_overs:recentovers,
bowling_table:bowlingtable};
}, function (err,result) {
scrapedMatchData = result;
browser.exit();
callback();
});
}, 5000);
});
});
});
});
The text was updated successfully, but these errors were encountered:
@himanshu1691 the common answer for such questions is - write script to run from phantom-js directly, then port to this driver. Or use more high-level libraries. If you are sure your problem is caused by driver - please provide a more short example.
As I mentioned in #153, page.evaluate cannot access variables defined outside of itself, other than document, window and other browser (not node variables) global variables.
How to navigagte using this package?
From a given URL, it should find out a link to another page and after loading that we should be able to scrape content from that. How can we do that here?
Here is the sample code which does not work. Can someone tell me why it doesn't work :
The text was updated successfully, but these errors were encountered: