Created
May 10, 2014 09:25
-
-
Save emilssolmanis/d002f76554101ea7d473 to your computer and use it in GitHub Desktop.
Expedia result scraping
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
$('.segment-result').each(function(i, flightModule) { | |
function getText(selector) { | |
return $(selector, flightModule).text().trim().replace(/\s+/g, ' '); | |
} | |
var srcCode = getText('[data-test-id=departureAirportCode]'); | |
var destCode = getText('[data-test-id=arrivalAirportCode]'); | |
var srcTime = getText('[data-test-id=departureTime]'); | |
var destTime = getText('[data-test-id=arrivalTime]'); | |
var duration = getText('[data-test-id=duration]').replace(',', ''); | |
var price = getText('.offer-price > span').replace(',', ''); | |
var airliner = $('.image-well > img', flightModule).attr('src').split('/').pop().split('.')[0]; | |
var stops = getText('[data-test-id=stops]'); | |
console.log('%s, %s, %s, %s, %s, %s, %s, %s', srcCode, destCode, srcTime, destTime, duration, price, airliner, stops); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment