【发布时间】:2015-09-30 12:37:27
【问题描述】:
我正在尝试遍历包含公司列表的目录。我已经用 selenium 编写了这段代码,它只会打开一个链接。我想像新标签中的每个链接一样打开并抓取一些信息。
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox() # Get local session of firefox
# 0 wait until the pages are loaded
browser.implicitly_wait(3) # 3 secs should be enough. if not, increase it
browser.get("http://ae.bizdirlib.com/taxonomy/term/1493") # Load page
link = browser.find_element_by_css_selector("h2 > a")
links.click()
这段代码怎么不会打开下一个链接。当我尝试遍历 link.click() 时,它给了我一个错误,例如“无法遍历 web 元素”
selenium web 驱动程序的新手。有人可以帮助我为我增强代码。
【问题讨论】:
标签: python-2.7 selenium selenium-webdriver