How can I get all the values of an attribute in a tag?
wxy1995 opened this issue · comments
wxy1995 commented
I want to get data with the following structure:
{
'imgUrls': [
'https://aa.png',
'https://bb.png',
'https://cc.png',
]
}
Is there any solution?
Wayne Connolly commented
The below will get you close and then you will have to use standard array manipulation to rebuild an array to suit your structure.
imgs: {
listItem: "div.photoContainer"
, name: "count"
, data: {
url: {
selector: "img"
, attr: "src"
}
}
}
This returns
imgs: [
{ url: 'https://img.com/123.jpg' },
{ url: 'https://img.com/1234.jpg' },
{ url: 'img.com/1235.jpg' }
],
Ionică Bizău (Johnny B.) commented
Yes, @wayneconnolly's answer should work. Please ask questions on Stackoverflow.