Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Cheerio js toma todas las direcciones que contienen solo texto

Tengo el siguiente código que me lleva todas las direcciones.

Solo necesito direcciones que contengan texto.

Ex:

<a href="https://www...." target="_blank">Text...</a>

Pero el problema de que hay direcciones que contienen una imagen, estas direcciones me gustaría excluirlas.

Ex:

<a href="http://www..." target="_blank"><img src="http://www." border="0" alt=""></a>

 $("div#posts > div > div > div > div > table > tbody > tr:nth-child(2) > td:nth-child(2) > div:nth-child(3)").each((_idx, el) => { $(el).find('a').each((_idx, el) => { let u = $(el).attr('href') if(u.includes("http")) element.add(u); }) })

¿Puedes darme una mano?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

intente seleccionar a que no tenga img (o tal vez ningún elemento secundario, si hay otros elementos), con una combinación de : tiene y : no

 $(el).find('a:not(:has(img))').each((_idx, el) => { let u = $(el).attr('href') if (u.includes("http")) element.add(u); })
about 4 years ago · Juan Pablo Isaza Report

0

Puedes usar el filtro:

 $('a').get().filter(a => $(a).text().match(/\w/)).map(a => $(a).attr('href'))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!