【发布时间】:2016-10-12 01:10:24
【问题描述】:
我选择了 Selenium,因为链接的 href 是动态生成的,尽管通过 bs4 的一些方法会更好。
我正在使用 PhantomJS,但也尝试过 Firefox
当试图点击一个链接时,什么也没有发生。
例如,
url = 'http://www.achema.de/de/ausstellung/aussteller-und-produkte.html'
driver.get(url)
resultsBox = driver.find_element_by_css_selector('div[id="ix_result"]')
for tr in resultsBox.find_elements_by_tag_name('tr'):
link = tr.find_element_by_tag_name('a')
link.click()
# I've also tried:
# ActionChains(driver).move_to_element(link).click(link).perform()
【问题讨论】:
-
你确定你正在迭代的集合有元素'a'吗?您应该提供测试输入以获得更好的答案。
标签: python selenium beautifulsoup