关于python网页抓取的关于无关的知识。使用Python从网页获取表格
我需要从this页面得到一个表:
http://performance.morningstar.com/funds/etf/total-returns.action?t=IWF
这是我现在有:
from selenium import webdriver
from bs4 import BeautifulSoup
# load chrome driver
driver = webdriver.Chrome('C:/.../chromedriver_win32/chromedriver')
# load web page and get source html
link = 'http://performance.morningstar.com/funds/etf/total-returns.action?t=IWF'
driver.get(link)
html = driver.page_source
# make soup and get all tables
soup = BeautifulSoup(html, 'html.parser')
tables = soup.findAll('table',{'class':'r_table3'})
tbl = tables[1] # ideally we should select table by name
我从哪里出发?
有没有什么建议同时使用BeautifulSoup和硒具体的原因是什么? – Goralight
有人告诉我,当页面嵌入JavaScript时,你需要先加载它,然后用美丽的方式解析? –
我并不是说这是问题,而是因为你需要它的原因 - 你需要整桌吗?或者一个特定的细胞? – Goralight