javascript - PhantomJS not returning any results -


i'm using phantomjs scrape data webpage. phantomjs not returning evaluate method. script runs few seconds , exits.

i've checked see if phantomjs connecting page -- is. phantomjs able grab page title. i've double-checked class i'm looking for, yes -- i'm spelling correctly.

var page = require('webpage').create();  page.open('http://www.maccosmetics.com/product/13854/36182/products/makeup/lips/lipstick/giambattista-valli-lipstick', function(status) {     page.includejs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {         waitfor(function()  {             return page.evaluate(function() {                 $('.product__price').is(':visible');             });         }, function(){             search = page.evaluate(function() {                 return  $('.product__price').text();             });             console.log(search)         });     });     phantom.exit(); }); 

i don't know what's going wrong here.

it's not showing anything, because you're exiting early. functions (except evaluate()) take callback asynchronous.

you're requesting include jquery in page calling page.includejs(), exit phantomjs. need exit when you're finished:

var page = require('webpage').create();  page.open('http://www.maccosmetics.com/product/13854/36182/products/makeup/lips/lipstick/giambattista-valli-lipstick', function(status) {     page.includejs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {         waitfor(function()  {             return page.evaluate(function() {                 $('.product__price').is(':visible');             });         }, function(){             search = page.evaluate(function() {                 return  $('.product__price').text();             });             console.log(search);             phantom.exit();         });     }); }); 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -