简体   繁体   English

我如何在 Cheerio<a>中使用带有 aria-label 的 select?</a>

[英]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例如得到一个包含孟加拉国这个词的

如何定位元素<div aria-label></div><div id="text_translate"><p>我在 selenium java 中非常初级。 我正在尝试在亚马逊中找到该元素。</p><p> 当我尝试运行此代码时,我找不到该元素。 请帮助解决这个问题。</p><p> <a href="https://i.stack.imgur.com/eMWTB.png" rel="nofollow noreferrer">在此处输入图像描述</a></p><p>这是我的代码</p><pre> WebElement a_review= driver.findElement(By.xpath("//div[@aria-label='4 Stars &amp; Up']")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", a_review); a_review.click();</pre></div> - how to locate the element in <div aria-label>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果以“示例”开头,我如何调用 aria-label - How can i call aria-label if it start with "Example" 如何将aria-label添加到selectize.js? - How can I add aria-label to selectize.js? 如何定位元素<div aria-label></div><div id="text_translate"><p>我在 selenium java 中非常初级。 我正在尝试在亚马逊中找到该元素。</p><p> 当我尝试运行此代码时,我找不到该元素。 请帮助解决这个问题。</p><p> <a href="https://i.stack.imgur.com/eMWTB.png" rel="nofollow noreferrer">在此处输入图像描述</a></p><p>这是我的代码</p><pre> WebElement a_review= driver.findElement(By.xpath("//div[@aria-label='4 Stars &amp; Up']")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", a_review); a_review.click();</pre></div> - how to locate the element in <div aria-label> 在按钮上添加 aria-label - Add aria-label on button 如何通过带有 Python Selenium 的 aria-label 找到并单击 JavaScript 按钮? - How to find and click a JavaScript button by aria-label with Python Selenium? 如何使屏幕阅读器在单击时读取按钮的aria标签 - How to make screenreader read the aria-label of a button while clicking Selenium Javascript:如何检查 aria-label 参数? - Selenium Javascript: how to check aria-label parameter? 我需要使用链接文本作为 aria 标签将 aria-label 添加到网站上的所有链接 - I need to add aria-label to all links on the website using the link text as aria label 带有aria标签的猫头鹰轮播2.2点 - owl carousel 2.2 dots with aria-label 使用xpath单击aria-label元素 - Click a aria-label element using xpath
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM