Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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在内置html页面上单击按钮执行数据获取_Python_Selenium_Selenium Webdriver - Fatal编程技术网

Python 如何使用selenium在内置html页面上单击按钮执行数据获取

Python 如何使用selenium在内置html页面上单击按钮执行数据获取,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我是Selenium的新手,我尝试在一个站点上模拟用户的操作,通过点击按钮从内置html页面获取数据。我可以填充所有字段的详细信息,但是按钮单击不起作用,看起来js代码没有运行 我尝试了很多选择,比如添加等待时间、动作链等,但都不起作用,我正在提供我编写的站点和代码 driver = webdriver.Chrome() driver.get("https://www1.nseindia.com/products/content/derivatives/equities/histori

我是Selenium的新手,我尝试在一个站点上模拟用户的操作,通过点击按钮从内置html页面获取数据。我可以填充所有字段的详细信息,但是按钮单击不起作用,看起来js代码没有运行

我尝试了很多选择,比如添加等待时间、动作链等,但都不起作用,我正在提供我编写的站点和代码

driver = webdriver.Chrome()
driver.get("https://www1.nseindia.com/products/content/derivatives/equities/historical_fo.htm")
driver.implicitly_wait(10)
将值分配给所有其他字段

driver.find_element_by_id('rdDateToDate').click()

Dfrom = driver.find_element_by_id('fromDate')
Dfrom.send_keys("02-Oct-2020")

Dto = driver.find_element_by_id('toDate')
Dto.send_keys("08-Oct-2020")

innerHTML = driver.execute_script("document.ready")
sleep(5)

getdata_btn = driver.find_element_by_id('getButton')
ActionChains(driver).move_to_element(getdata_btn).click().click().perform()

我建议使用完整的xpath

chrome.get("https://www1.nseindia.com/products/content/derivatives/equities/historical_fo.htm")
time.sleep(2)
print("click")
fullxpath = "/html/body/div[2]/div[3]/div[2]/div[1]/div[3]/div/div[1]/div/form/div[19]/p[2]/input"
chrome.find_element_by_xpath(fullxpath).click()
我尝试过点击按钮,它与XPath一起工作。。。我认为这是因为有人在一个网站上使用了两次ID,但我找不到它。。。所以我不知道那里出了什么问题


祝你好运:)

我尝试了完整的xpath,但出现错误,说它的图像不是按钮,不知道如何找到并单击按钮。它是手动进行的,但无法自动进行。感谢您的回复。尝试复制粘贴我给您的代码,看看我是否已经尝试过了,并且出现了错误“element ClickInterception:element click Interception:element在点(255548)处不可单击。其他元素将收到单击:
  • (会话信息:chrome=86.0.4240.75)”我甚至尝试了半自动化,只使用selenium打开页面,然后手动尝试填充数据并单击按钮,但即使如此,它也无法获取数据,而完全是通过手动操作获取的。网站是否存在自动化受到限制的限制?有人请帮忙。