【发布时间】:2017-04-18 23:19:22
【问题描述】:
我正在使用 python selenium 脚本从 UPS 网站提取邮政编码之间的运输时间。 "http://ltl.upsfreight.com/shipping/transittimes/transittimes.aspx"
我的代码在我尝试捕获运输时间之前一直有效。如何获取价值?下面是来自 chrome 的 html,其中包含我要捕获的值“1”。
<span id="app_ctl00_ctl01_lblServiceDays" style="font-weight:bold;">1</span>
还有代码本身:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://ltl.upsfreight.com/shipping/transittimes/transittimes.aspx')
driver.find_element_by_id("app_ctl00_ctl00_OriginZipCodeSelector_OriginZipCodeSelector_txtZip").clear()
driver.find_element_by_id("app_ctl00_ctl00_OriginZipCodeSelector_OriginZipCodeSelector_txtZip").send_keys("07042")
driver.find_element_by_id("app_ctl00_ctl00_DestinationZipCodeSelector_DestinationZipCodeSelector_txtZip").clear()
driver.find_element_by_id("app_ctl00_ctl00_DestinationZipCodeSelector_DestinationZipCodeSelector_txtZip").send_keys("07059")
driver.find_element_by_id("app_ctl00_ctl00_btnSubmit").click()
shiptime = driver.find_element_by_id("app_ctl00_ctl01_lblServiceDays")
print (shiptime)
【问题讨论】:
标签: python html selenium automation