我需要循环浏览此页面上的选择菜单:
https://printcopy.info/?mod=erc&brand=Kyocera&model=TASKalfa+307ci&page=1
选择菜单有一个显示:无,因此我执行了以下操作以获取值:
element = driver.find_element_by_id('selectNumPages')
driver.execute_script("return arguments[0].removeAttribute('style');", element)
select = Select(driver.find_element_by_id('selectNumPages'))
for opt in select.options:
print(opt.text)
这将输出选择菜单中的每个值,现在我需要单击每个值,以便在每页上刮取数据
我试过:
button = driver.find_element_by_id("selectNumPages-button")
button.click()
单击“选择”菜单,但页面url不变
任何帮助都将不胜感激
更新
我最终使用了ActionChains
这是自定义下拉列表。您可以参考以下代码:
输出:
如果要循环浏览页面,则无需单击每个页面。您只能获取每个页面的url
https://printcopy.info/?mod=erc&brand=Kyocera&model=TASKalfa+307ci&page=1
如您所见,这里有“page=1”。您可以使用它来循环浏览页面。总共有23页
然后只需选择您需要的项目
另外,我也是新手,如果我错了,请纠正我
相关问题 更多 >
编程相关推荐