我需要创建一个自动化程序来填写此链接中的注册表:https://coterieinsurance.com/agentero/
我正在测试填写机构名称,但我不断收到错误消息,指出“input-53”不存在。一旦我弄清楚如何克服这个问题,我就可以转向其他领域。
有谁知道这个错误从何而来?或者我应该使用正确的 html 源是什么?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import json
import time
# Define the JSON data
json_data = {
"EventID": "10204699324324573",
"Requested_time": "17:54:42.864000+00:00",
"agency": {
"FEIN": "26-4430090",
"NPN": "13468670",
"address": {
"city": "SAN ANTONIO",
"state": "TX",
"street": "2042 OAK PKY 105",
"zip_code": "78289"
},
"contact_info": [
{"email": "[email protected]", "phone_number": "2100086000", "source": "Agency"},
{"email": "", "phone_number": "210-008-6000", "source": "NIPR"}
],
"email": "[email protected]",
"agency_name": "AGENTERO AGENCY, LLC"
},
"agent": {
"NPN": "3800006",
"email": "[email protected]",
"first_name": "Jhon",
"last_name": "Smith",
"phone_number": "2108966000",
"title_position": "Owner",
"validated": True
},
"carrier": "Coterie",
"request": {
"questions": {"accept_terms": "true", "why_appointment": None},
"status": "APPROVED"
},
"requested_at": "T17:54:42.616754562Z"
}
# Initialize the WebDriver
driver = webdriver.Chrome()
try:
# Navigate to the target website
driver.get("https://coterieinsurance.com/agentero/")
# Fill out the form fields (replace these selectors with the actual ones)
driver.find_element(By.ID, "input-53").send_keys(json_data["agency"]["agency_name"])
finally:
# Pause to allow inspection of the filled form
time.sleep(10)
# Clean up and close the WebDriver
driver.quit()
输入位于 iframe 中,而不是根 html 中。 在 driver.find_element 之前添加此代码
driver.switch_to.frame(0)