gpt4 book ai didi

python - 使用 Python 填写 Web 表单

转载 作者:太空宇宙 更新时间:2023-11-04 05:24:36 28 4
gpt4 key购买 nike

我一直在尝试使用 Python 中的 Selenium 填写网络表单。这是一个足够简单的任务,我使用的代码是这样的:

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

driver = webdriver.Firefox()
driver.get("https://...")
elem = driver.find_element_by_id("receipt_number")
elem.clear()
elem.send_keys("13lettercode")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

检查 Web 表单元素后,我得到了这个:

<input id="receipt_number" name="appReceiptNum" type="text" class="form-control textbox" maxlength="13">

该网站给我一个错误,说我的代码无效,我想知道是否有任何明显的地方我做错了。感谢您的帮助!

最佳答案

点击提交按钮而不是发送返回键

关于python - 使用 Python 填写 Web 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39215539/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com