您好,我正在尝试单击这些链接,但当我尝试使用
driver.find_element_by_xpath('//*[@id="productDetails_detailBullets_sections1"]/tbody/tr[6]/td/span/span[2]/a').click()
它的工作,但问题是每个项目都有不同的路径和它的变化,它不适用于某些项目
网址:https://www.amazon.com/MICHELANGELO-Piece-Rainbow-Kitchen-Knife/dp/B074T6C4YS/ref=zg_bs_289857_1?_encoding=UTF8&psc=1&refRID=K5GAX1GF2SDZMN3NS403>
Tags:
{a1}有3个条目用于畅销书排名。一种有效的方法是收集所有三(3)畅销书中的
href
,将它们存储在一个列表中,并在一个单独的选项卡中打开以进行刮取。要构造列表,必须为visibility_of_all_elements_located()
归纳WebDriverWait,并且可以使用以下Locator Strategies之一:使用
CSS_SELECTOR
:在一行中使用
CSS_SELECTOR
:控制台输出:
注意:您必须添加以下导入:
这很简单,即使您没有指定要使用哪个链接,也只是从表中选择了将您传输到表的所有不同链接
您需要使用定制的xpath,例如
我将是for循环中的迭代器。为了获得价值,我使用了
相关问题 更多 >
编程相关推荐