I’m quite new to coding and i’m struggling with returning multiple URLs and Descriptions from a block of HTML code. I know i have to loop it somehow but don’t know how. Hope someone can help me please. What i have is
function pageFunction(context) {
const $ = context.jQuery;
const venueName = $('div.collist a').first().text() + ' /';
const venueURL = $('div.collist a[href]').attr('href');
return {
venueName,
venueURL
};
The HTML code i’m trying to scrape is
</div>
<div class="collist">
<h3>Properties</h3>x
<ul class="list-unstyled">
<li>
<a href="search?query=500" rel="nofollow" title="Venue1"><span>London, UK</span></a> (<span>810</span>)
</li><li>
<a href="search?query=600" rel="nofollow" title="Venue2"><span>Pretoria, South Africa</span></a> (<span>820</span>)
</li><li>
<a href="search?query=700" rel="nofollow" title="Venue3"><span>New York, USA</span></a> (<span>830</span>)
</li><li>
<a href="search?query=800" rel="nofollow" title="Venue4"><span>Paris, France</span></a> (<span>840</span>)
</li><li>
<a href="search?query=900" rel="nofollow" title="Venue5"><span>Denver, USA</span></a> (<span>850</span>)
</li><li>
<a href="search?query=1000" rel="nofollow" title="Venue6"><span>Deli, India</span></a> (<span>860</span>)
</li><li>
<a href="search?query=1100" rel="nofollow" title="Venue7"><span>Lisbon, Protugal</span></a> (<span>870</span>)
</li><li>
<a href="search?query=1200" rel="nofollow" title="Venue8"><span>Madrid, Spain/span></a> (<span>880</span>)
</li><li>
<a href="search?query=1300" rel="nofollow" title="Venue9><span>Berlin, Germany</span></a> (<span>890</span>)
</li><li>
<a href="search?query=1400" rel="nofollow" title="Venue10"><span>Stockholm, Sweden</span></a> (<span>900</span>)
</li>
</ul>
My current results are
[{
"venueName": "London, UK /",
"venueURL": "search?query=500"
}]
But what i would like to see
[{
"venueName": "London, UK /","venueURL": "search?query=500"
"venueName": "London, UK /","venueURL": "search?query=600"
"venueName": "Pretoria, South Africa /","venueURL": "search?query=700"
"venueName": "New York, USA /","venueURL": "search?query=800"
"venueName": "Paris, France /","venueURL": "search?query=900"
}]
