【发布时间】:2021-10-27 02:16:26
【问题描述】:
正如我的标题所述,我收到一个错误,我的 selenium 给我一个错误,说 web 元素不可交互。基本上,我在圣克拉拉县税务包裹网站 (https://payments.sccgov.org/propertytax/Secured) 上并尝试使用硒来提取土地价值和税额的税单。我有一个包含所有税 APN 编号的 for 循环,应该循环通过每一个来拉取相关信息。去年我使用了相同的代码,一切都很好。出于某种原因,今年相同的代码不再有效。我猜他们实现了一些阻止 selenium 与 web 元素交互的东西。
我尝试使用等待计时器和 time.sleep 来确保 Web 元素加载,但这不是问题。如果我在查找之前使用 .wait 加载元素,则代码将永远等待直到超时。
感谢任何帮助!以下是我的代码:
for num, county in zip(lstOfParcelNums, lstofCounties):
# get Santa Clara's tax website
if "Santa Clara" in lstofCounties[count]:
site.get('https://payments.sccgov.org/propertytax/Secured')
time.sleep(5)
#Inputting parcel number in search
apn = site.find_element_by_xpath('//*[@id="ParcelNumber"]')
apn.send_keys(num)
go = site.find_element_by_xpath('//*[@id="ParcelSubmit"]')
go.click()
baldue1 = site.find_element_by_xpath('//*[@id="select_invoiceslist"]/div[1]/div[3]/div[2]/div[8]').text
baldue2 = site.find_element_by_xpath('//*[@id="select_invoiceslist"]/div[1]/div[3]/div[4]/div[8]').text
landval = site.find_element_by_id('billdetailstablemain').text
#Populating into excel
#Data
fetchedData.cell(count+2,7,value = baldue1)
fetchedData.cell(count+2,8,value = baldue2)
wb.save("C:/Users/Custom Gaming PC/Desktop/Python/Projects/2019-20 Tax APN Output.xlsx")
count+=1
【问题讨论】: