phantomstig
Version:
PhantomStig ===========
35 lines (27 loc) • 723 B
Markdown
PhantomStig
===========
Use PhantomJS in nodejs without having to write so many callback functions.
[](http://phantomjs.org/)
`npm install phantomstig --save-dev`
SearchBing.js
```
var PhantomStig = require('phantomstig');
var startUrl = 'http://bing.com';
var searchQuery = 'Junior JS';
console.log('Searching bing...');
var stig = new PhantomStig();
stig.open(startUrl);
stig.waitForElement('#sb_form_q');
stig.setElementValue('#sb_form_q', searchQuery);
stig.submitForm('#sb_form');
stig.waitForElement('.sb_tlst');
stig.getText('.sb_tlst', function (text) {
console.log('This was the top result: "' + text + '"');
});
stig.run();
```
`> node SearchBing.js`