HtmlUnitDriver (HtmlUnit) vs GhostDriver (PhantomJS)?

From my experience with a number of headless browsers, I’d say: HtmlUnitDriver: the fastest of all implementations I’ve come across, and perfect for simple, static pages, especially those without JavaScript. Any remotely complex page seems to produce problems – that’s my practical experience even if I can’t justify in detail. Perfect for testing Selenium features … Read more

PhantomJS fails to open local file

PhantomJS can open local files without any problems. The url have to follow classic Url/Uri rules, especially for a local file. /Full/Path/To/test.html is not valid for PhantomJS. Is it a local file or a web resource? Depending of the path, just try with something like this: file:///C:/Full/Path/To/test.html or if it’s hosted in a web server: … Read more

How can I scrape pages with dynamic content using node.js?

Here you go; var phantom = require(‘phantom’); phantom.create(function (ph) { ph.createPage(function (page) { var url = “http://www.bdtong.co.kr/index.php?c_category=C02”; page.open(url, function() { page.includeJs(“http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js”, function() { page.evaluate(function() { $(‘.listMain > li’).each(function () { console.log($(this).find(‘a’).attr(‘href’)); }); }, function(){ ph.exit() }); }); }); }); });

How to login into a website with CasperJS?

You will need to use Casper fill() function. Below is an example which login to Facebook and print out your name after login. Note that you need to put in your username and password: var casper = require(‘casper’).create({ verbose: true, logLevel: ‘debug’, pageSettings: { loadImages: false, // The WebPage instance used by Casper will loadPlugins: … Read more

Does PhantomJS support cookies?

Yes, as of 1.7 Phantom has complete cookie handling, enabled by default. Cookies are retained for the duration of the process’s life. If you’d like to retain cookies across runs of Phantom, there’s a command-line option cookies-file where you can specify where to store persistent cookies. –cookies-file=/path/to/cookies.txt specifies the file name to store the persistent … Read more

Scrape a webpage and navigate by clicking buttons

Zombie.js and Node.io run on JSDOM, hence your options are either going with JSDOM (or any equivalent wrapper), a headless browser (PhantomJS, SlimerJS) or Cheerio. JSDOM is fairly slow because it has to recreate DOM and CSSOM in Node.js. PhantomJS/SlimerJS are proper headless browsers, thus performances are ok and those are also very reliable. Cheerio … Read more

Is it possible to use Selenium WebDriver to drive PhantomJS?

PhantomJS now includes the GhostDriver project. You are also suggested to use PhantomJS directly or with a convenience library such as CasperJS. CasperJS is specifically designed to make it easy to do sequential operations to web pages, perfect for many automation tasks. Disclaimer: I am the author of PhantomJS. Edit: As noted in Nick’s answer, … Read more

phantomjs: command not found

The PATH really is the important part. You can skip it, however, if you specify the absolute path. Try something like this: /path/to/phantomjs render_image.js …but that can get tiring. For a quick way to add it to your PATH, from the directory of the phantomjs executable, symbolically link it into /usr/local/bin: sudo ln -s /path/to/phantomjs … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)