-
-
Save taylorsmcclure/76d1ecd7f999b009f6b4f8c03c600a97 to your computer and use it in GitHub Desktop.
nightmare airline example
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(); | |
// Command line options | |
var originAirport = "SEA" | |
var destinationAirport = "DFW" | |
var outboundDateString = "01/10/2017" | |
var returnDateString = "01/22/2017" | |
var adultPassengerCount = 1 | |
var interval = 30 // In minutes | |
nightmare | |
.goto('http://delta.com') | |
.insert('#originCity',[originAirport]) | |
.insert('#destinationCity', [destinationAirport]) | |
.insert('#departureDate', [outboundDateString]) | |
.insert('#returnDate', [returnDateString]) | |
.insert('#paxCount', [adultPassengerCount]) | |
.click('#findFlightsSubmit') | |
.wait('.priceBfrDec') | |
.evaluate(function () { | |
return document.querySelector('.priceBfrDec').innerHTML; | |
}) | |
.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