mirror of
https://github.com/matthewmueller/x-ray.git
synced 2026-04-03 00:28:41 -06:00
For Loop Only Crawls First Link #44
Labels
No labels
bug
bug
docs
duplicated
enhancement
enhancement
enhancement
enhancement
feature
feature
help wanted
question
ready for contributor
stale
tech support
tech support
tech support
tech support
tech support
tech support
tech support
tech support
tech support
tech support
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github/x-ray#44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @arlingtonkirk on 10/24/2019
The site I'm trying to crawl is rendered by JS and the links use onClick with # as the value for href. I've successfully constructed the links via a filter, but for some reason can't crawl them in a for loop. See code below.
Your environment
Expected behaviour
Console should spit out 10 elements.
Actual behaviour
Console only outputs first item.
var phantom = require('x-ray-phantom');
var Xray = require('..');
var x = Xray({
filters: {
makeLink: function(value) {
if(value) {
var str1 = 'https://hsbc.taleo.net/careersection/external/jobdetail.ftl?lang=en_GB&job='
var value = str1.concat(value);
}
return typeof value === 'string'
? value
: null
}
}
})
.driver(phantom({webSecurity:false}));
x('https://hsbc.taleo.net/careersection/external/moresearch.ftl?lang=en_GB&dropListSize=10', '.ftlrow', [
{
link: '.editablesection div:nth-child(3) span:nth-child(5) | makeLink',
}
]).then(function(myObj) {
})