-
-
Save rrgayhart/f1c25fd47bb5ad42957224e8b6b5ba83 to your computer and use it in GitHub Desktop.
dominos-scrape-example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Nightmare = require('nightmare'); | |
var nightmare = Nightmare({ show: true }); | |
nightmare | |
.goto('https://www.dominos.com/en/') | |
.wait('.btn--delivery') | |
.click('.btn--delivery') | |
.wait('input#Street') | |
.wait(1000) | |
.type('input#Street[type=\'text\'][name=\'Street\']', 'Made Up Street Address') | |
.type('input#City', 'Denver') | |
.select('select#Region', 'CO') | |
.type('label[for=\'Postal_Code\']', '80203') | |
.click('button.btn--large[type=\'submit\']') | |
.wait(2000) | |
.evaluate(function (result, done) { | |
var deliveryError = document.querySelector('.errorText') | |
if (deliveryError) { | |
return deliveryError.innerHTML; | |
} else { | |
return 'A pizza can be delivered to you!' | |
} | |
}) | |
.end() | |
.then(function (result) { | |
console.log(result) | |
}) | |
.catch(function (error) { | |
console.error('Search failed:', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment