Python 如何使用selenium选择某些按钮
我需要selenium选择一个html代码为的按钮:Python 如何使用selenium选择某些按钮,python,html,python-3.x,selenium,selenium-webdriver,Python,Html,Python 3.x,Selenium,Selenium Webdriver,我需要selenium选择一个html代码为的按钮: <a href="stuMain.php?datasetID=31561">583</a> 您可以执行以下操作: a = driver.execute_script(""" return [...document.querySelectorAll('a[href*="datasetID="]')].find(a => a.innerText.match(/^\d+$/)) """) 在python中获取和
<a href="stuMain.php?datasetID=31561">583</a>
您可以执行以下操作:
a = driver.execute_script("""
return [...document.querySelectorAll('a[href*="datasetID="]')].find(a => a.innerText.match(/^\d+$/))
""")
在python中获取和过滤这些可能更简单。您是否尝试在代码中使用selenium?请向我们提供您的一些代码
驱动程序。通过xpath('//a[@href=“'+url+'“]”)查找\u元素\u
url是stuMain.php?datasetID=31561
,因此您可以单击您想要的不起作用的链接,它给出的错误没有这样的元素,只是它说没有这样的元素:))尝试查看更多关于selenium
的信息,它可以在多个逻辑中处理。也许你可以先试试这个:如果它不起作用,我们可以解决它。
<font color="red">579</font>
<a href="preview.php?datasetID=31557">View</a>
dataset = driver.find_element_by_tag_name('a')
dataset.click()
a = driver.execute_script("""
return [...document.querySelectorAll('a[href*="datasetID="]')].find(a => a.innerText.match(/^\d+$/))
""")