【发布时间】:2014-09-03 20:40:46
【问题描述】:
我目前正在使用 Selenium 和 BeautifulSoup 来尝试从 Google 财经中抓取财务报表数据。例如:
http://www.google.com/finance?q=GOOG&fstype=ii
打开 Google 损益表。当我让 Selenium 点击页面顶部的“Balance Statement”和“Cash Flow”按钮时,页面上的图表和表格发生了变化,但 url 没有改变,当我拉页面源时,它是损益表表的原始页面。我的代码贴在下面:
driver = webdriver.Firefox()
driver.get("http://www.google.com/finance?q=" + ticker[0] + "&fstype=ii")
url1 = driver.page_source
soup1 = BeautifulSoup(url1)
element = driver.find_element_by_xpath('//*[@id=":1"]/a/b/b')
element.click()
driver.implicity_wait(3.0)
url2 = driver.page_source
soup2 = BeautifulSoup(url2)
element = driver.find_element_by_xpath('//*[@id=":2"]/a/b/b')
element.click()
driver.implicity_wait(3.0)
url3 = driver.page_source
soup3 = BeautifulSoup(url3)
driver.quit()
感谢任何帮助。谢谢。
【问题讨论】:
标签: python selenium web-scraping beautifulsoup