<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> Quiero extraer un enlace de una página web usando cheerio de class="views-field views-field-title" . Hay tantos enlaces a la página web, pero solo quiero extraer de la clase mencionada.
Según el fragmento HTML que compartió, el siguiente fragmento podrá recuperar todos los hipervínculos.
<!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>