[英]How do i select <a> with aria-label in cheerio?
I am currently building a scraper which scrapes data from newspaper sites based on the keyword I am looking for, such as "environment" and "climate".我目前正在构建一个刮板,它根据我正在寻找的关键字(例如“环境”和“气候”)从报纸网站上刮取数据。 But I have recently encountered a site where I couldn't simply check if the text has my desired keywords.但我最近遇到了一个网站,我不能简单地检查文本是否有我想要的关键字。 Its HTML is written in this way它的HTML就是这样写的
<a aria-label="Ravaged by floods, Bangladesh pitches plan to adapt to climate impacts" class="card-with-image-zoom" href="https://en.prothomalo.com/environment/climate-change/ravaged-by-floods-bangladesh-pitches-plan-to-adapt-to-climate-impacts">
Here is how i am looking for keywords using cheerio-这是我使用cheerio-寻找关键字的方式
const html = response.data;
const $ = cheerio.load(html);
const specificarticles = [];
$('a:contains("climate"),a:contains("environment")',HTML)
How do i check the keyword availability of this specific HTML using cheerio?如何使用 Cheerio 检查此特定 HTML 的关键字可用性?
If it uses normal selectors, try如果它使用普通选择器,请尝试
$("a[aria-label]")
for all and为所有人和
$("a[aria-label*=Bangladesh]")
for example to get one with the word Bangladesh in it例如得到一个包含孟加拉国这个词的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.