我使用selenium webdriver编写了一个python脚本来从一个网站获取一些数据,并且 我正试图单击this网页中的“下一步”按钮。定义按钮的位置:
<a id="ctl00_FullRegion_npsGridView_lnkNext" class="nextCol" href="javascript:__doPostBack('ctl00$FullRegion$npsGridView$lnkNext','')">Next</a>
用python编写以下代码
URL='http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/'
nextId="ctl00_FullRegion_npsGridView_lnkNext"
browser=webdriver.PhantomJS('./phantomjs')
browser.get(URL)
nextBtn=browser.find_element_by_id(nextId)
time.sleep(5)
nextBtn.click()
当使用Firefox或chrome Webdriver时,这很好,但是对于Phantomjs,我会得到以下错误。
selenium.common.exceptions.WebDriverException: Message: u'Error Message => \'Click
failed: ReferenceError: Can\'t find variable: __doPostBack\'\n caused by Request
这个错误出现在很多google搜索中,但是在使用phantomjs时,还没有找到一种解决方法。
尝试发送其他用户代理头:
相关问题 更多 >
编程相关推荐