代码之家  ›  专栏  ›  技术社区  ›  FabricioG

Puppeteer js id元素包含

  •  0
  • FabricioG  · 技术社区  · 5 年前

    *[@id="content_gvNewLeads_tccell0_5"]/a
    

    我需要得到这些元素中的每一个,一页上大约有200个。每个id都略有变化。

    我试过这个:

      const aLink = await page.$x('//id[contains(content_gvNewLeads_tccel)]/a')
    

    我犯了个错误,你知道我该怎么做吗?

    0 回复  |  直到 5 年前
        1
  •  1
  •   mbit    5 年前

    请尝试以下XPath:

    const aLink = await page.$x('//*[contains(@id,"content_gvNewLeads_tccel")]/a')