【发布时间】:2016-08-26 07:30:03
【问题描述】:
我正在尝试抓取此页面:
http://www.1800contractor.com/d.HI.html
这个脚本是我写的
from selenium import webdriver
URL = "http://www.1800contractor.com/d.GA.html"
zip_codes = ['30324']
driver = webdriver.Firefox()
driver.get(URL)
zip_codes = ['30324']
text_box = driver.find_element_by_xpath('//*[@id="zip"]')
text_box.send_keys(zip_codes[0])
button = driver.find_element_by_xpath('//*[@id="xmdListingsSearchForm"]')
button.click()
基本上我需要在搜索框中输入一个邮政编码:
zip_codes = ['30324']
text_box = driver.find_element_by_xpath('//*[@id="zip"]')
text_box.send_keys(zip_codes[0])
那部分工作正常。
然后点击“开始”按钮:
button = driver.find_element_by_xpath('//*[@id="xmdListingsSearchForm"]')
button.click()
那部分不起作用,这是我在该按钮的 html 中看到的:
<input type="image" src="/rfs/servicerequest/images/go_btn_grey_20x20.gif" height="20" width="20" style="position: relative; top: 1px;">
所以我想问题是我没有得到对实际按钮的引用,而是对按钮图像的引用。
【问题讨论】:
标签: python html selenium web-scraping web-crawler