Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用selenium选择某些按钮_Python_Html_Python 3.x_Selenium_Selenium Webdriver - Fatal编程技术网

Python 如何使用selenium选择某些按钮

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中获取和

我需要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中获取和过滤这些可能更简单。

您是否尝试在代码中使用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+$/))
""")