【发布时间】:2015-06-05 18:25:03
【问题描述】:
我正在尝试从该网站获取塞浦路斯所有住宿的链接: http://www.zoover.nl/cyprus
到目前为止,我可以检索已经显示的前 15 个。所以现在我必须调用“volgende”链接上的点击。但是我不知道该怎么做,并且在源代码中我无法追踪调用使用的函数,例如某事喜欢张贴在这里: Issues with invoking "on click event" on the html page using beautiful soup in Python
我只需要发生“点击”的步骤,这样我就可以获取接下来的 15 个链接等等。
有人知道怎么帮忙吗? 已经谢谢了!
编辑:
我的代码现在看起来像这样:
def getZooverLinks(country):
zooverWeb = "http://www.zoover.nl/"
url = zooverWeb + country
parsedZooverWeb = parseURL(url)
driver = webdriver.Firefox()
driver.get(url)
button = driver.find_element_by_class_name("next")
links = []
for page in xrange(1,3):
for item in parsedZooverWeb.find_all(attrs={'class': 'blue2'}):
for link in item.find_all('a'):
newLink = zooverWeb + link.get('href')
links.append(newLink)
button.click()'
我收到以下错误:
selenium.common.exceptions.StaleElementReferenceException:消息:元素不再附加到 DOM 堆栈跟踪: 在 fxdriver.cache.getElementAt (resource://fxdriver/modules/web-element-cache.js:8956) 在 Utils.getElementAt (file:///var/folders/n4/fhvhqlmx23s8ppxbrxrpws3c0000gn/T/tmpKFL43_/extensions/fxdriver@googlecode.com/components/command-processor.js:8546) 在 fxdriver.preconditions.visible (file:///var/folders/n4/fhvhqlmx23s8ppxbrxrpws3c0000gn/T/tmpKFL43_/extensions/fxdriver@googlecode.com/components/command-processor.js:9585) 在 DelayedCommand.prototype.checkPreconditions_ (file:///var/folders/n4/fhvhqlmx23s8ppxbrxrpws3c0000gn/T/tmpKFL43_/extensions/fxdriver@googlecode.com/components/command-processor.js:12257) 在 DelayedCommand.prototype.executeInternal_/h (file:///var/folders/n4/fhvhqlmx23s8ppxbrxrpws3c0000gn/T/tmpKFL43_/extensions/fxdriver@googlecode.com/components/command-processor.js:12274) 在 DelayedCommand.prototype.executeInternal_ (file:///var/folders/n4/fhvhqlmx23s8ppxbrxrpws3c0000gn/T/tmpKFL43_/extensions/fxdriver@googlecode.com/components/command-processor.js:12279) 在 DelayedCommand.prototype.execute/
我很困惑:/
【问题讨论】:
标签: javascript jquery python beautifulsoup pyqt4