Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.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+;chrom webdriver)_Python_Selenium_Selenium Webdriver - Fatal编程技术网

如何使用自动填充字段提取表单数据(使用python+;selenium+;chrom webdriver)

如何使用自动填充字段提取表单数据(使用python+;selenium+;chrom webdriver),python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我使用selenium和web驱动程序在python中工作 from selenium import webdriver from selenium.webdriver.common.keys import Keys path="E:\Allah Kareem HelpmeGuid me\chromedriver.exe" driver= webdriver.Chrome(path) driver.get("https://lsg3.nlm.nih.gov/web

我使用selenium和web驱动程序在python中工作

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

path="E:\Allah Kareem HelpmeGuid me\chromedriver.exe"
driver= webdriver.Chrome(path)
driver.get("https://lsg3.nlm.nih.gov/webapps/WebTc.2011/jsp/jdi/vJdi.jsp")

search=driver.find_element_by_name('IN_TERM ')
print(search)
search.send_keys("Glutathione S-transferase-dependent"+Keys.ENTER)
search.send_keys(Keys.RETURN)

driver.quit()
但我犯了个错误

回溯(最近一次调用):文件“E:\Guide\u me\selenum.py”,第9行,在 搜索=驱动程序。按文件“E:\Allah Kareem HelpmeGuid”中的名称(“术语”)查找元素 me\lib\site packages\selenium\webdriver\remote\webdriver.py“,第行 496,在按名称查找元素中 返回self.find_元素(by=by.NAME,value=NAME)文件“E:\Allah Kareem helpmaguid me\lib\site packages\selenium\webdriver\remote\webdriver.py“,第行 978,在find_元素中 'value':value})['value']文件“E:\Allah Kareem helpmaguid me\lib\site packages\selenium\webdriver\remote\webdriver.py”,第行 321,执行中 self.error\u handler.check\u响应(response)文件“E:\Allah Kareem helpmaguid me\lib\site packages\selenium\webdriver\remote\errorhandler.py“,第行 242,在check_响应中 引发异常类(消息、屏幕、堆栈跟踪)selenium.common.exceptions.NoSuchElementException:消息:无此类 元素:找不到元素:{“方法”:“css” 选择器“,”选择器“:“[name=”IN_TERM”]”}(会话信息: 铬=86.0.4240.75)

请检查我的代码和错误 输入网页只包含一个输入,然后GO将执行,结果将显示在文本区域中
提前感谢

您在元素名称的末尾添加了额外的空格。更改此行:

search=driver.find_element_by_name('IN_TERM ')
为此:

search=driver.find_element_by_name('IN_TERM')
是的,谢谢你 这只是因为一个空格后的IN_术语

search=driver.find_element_by_name('IN_TERM')

您确定i)元素的名称在\u TERM中吗?ii)术语中的
后面有一个空格?如果没有,请尝试删除
driver处的空格。按\u名称(“IN\u TERM”)查找\u元素\u
是的……应该是“任期内”而不是“任期内”。我在回答中也提到了同样的问题。YW!你能接受我的答案作为最佳答案吗?你所要做的就是点击“向上投票”按钮下方的绿色勾号。另外,接受最佳答案会让你得到2分!对不起,我不知道规则,这只是为了回答的确认这在堆栈溢出中不是一个好的实践。在堆栈溢出中,如果有人提供了最佳答案,您必须通过单击他们答案附近的绿色勾号来接受它作为最佳答案。这是因为他们会花费大量时间来提供正确答案,因此这是som这是对他们的一种奖励。所以请删除此答案,并接受我的答案作为最佳答案。接受我的答案也将帮助你获得2个声誉!