单击 puppeteer 中的cheerio 元素

问题描述

我使用 Puppeteer 和 Cheerio 在 Node JS 中制作了一个网页抓取脚本。到目前为止它工作正常,但我现在的问题是希望能够与我在cheerio中找到的元素进行交互(点击)。

我曾尝试提取 xpath 和其他问题,但似乎不起作用。

我尝试返回整个查询选择器,但没有成功。当我尝试使用 puppeteer 将cheerio 中的相同语法用于单个查询选择器时,它失败了....


puppeteer.launch({headless: false})
.then(async (browser) =>{
  let page = await browser.newPage();
  page.goto(providerUrl)
  .then(async () =>{
    const content = page.content();
    content.then(success =>{
      const $ = cheerio.load(success);
      const wrapperChildren = $('.providerCardOut > div').children()
      wrapperChildren.each(async (index,elem) =>{
        //how to click this element,when it is found. 
        const clickableButton = $(elem).find('.providerCard-spoiler-title providerCard-closed')
    })
  })
})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)