Closed ivansabik closed 9 years ago
I'm very new to using x-ray, but I think you would want to use the following:
var Xray = require('x-ray'); var x = Xray(); var URL = 'https://tools.usps.com/go/TrackConfirmAction.action?tRef=fullpage&tLc=1&tLabels=9449309699938393515880'; x(URL, 'div.tracking-summary', ['span'])(function(err, scraped) { console.log(scraped) })
The results would be:
[ 'Tracking Number: ', ' 9449309699938393515880 ', 'Updated Delivery Day:', '\r\n\t\t\t\t\t\t\t\t\t\t\tTuesday, April 28, 2015\r\n\t\t\t\t\t\t\t\t\t\t\t', '', 'Signed for By:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tS MARSH // ANKENY, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\tIA \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t50023 // \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t1:09 pm ' ]
you might need to use x-ray-phantom if the content you're trying to scrape is loaded using javascript
good thanks a lot, still wondering why the example I gave doesnt find all labels
Could you help me understanding why the following code only finds one result? Im trying:
The above returns:
However in the HTML there's also this:
and this:
Maybe Im not getting how selectors work in xray, cheers