<td class="views-field views-field-title">
<a href="xxxxxxx" class="cat-job-rate recruiter-colorbox-processed">
xxxxxx
</a><br>
<span class="job-label">Organization:</span>
xxxxx | <span class="job-label">xxxxxx:</span>
xxxx | <span class="job-label">xxxx:</span> xxxxx
</td>
I want to extract a link from a webpage using cheerio from the class="views-field views-field-title". There are so many a links on the webpage but I want to extract from the mentioned class only.
As per HTML snippet you shared, below snippet will able to retrieve all the hyperlinks.
<!DOCTYPE html>
<html>
<head>
<script>
function getHyperlinks() {
var parent = document.querySelectorAll(".views-field.views-field-title > a");
for(let i = 0; i < parent.length; i++) {
console.log(parent[i].getAttribute("href"))
}
}
</script>
</head>
<body>
<h2>My First JavaScript</h2>
<table>
<td class="views-field views-field-title"> <a href="xxxxxxx" class="cat-job-rate recruiter-colorbox-processed">xxxxxx</a>
<br><span class="job-label">Organization:</span> xxxxx | <span class="job-label">xxxxxx:</span>xxxx | <span class="job-label">xxxx:</span> xxxxx </td>
</table>
<input type="button" onclick="getHyperlinks();" value="click" /> </body>
</html>