【发布时间】:2014-07-24 12:26:51
【问题描述】:
我正在尝试使用 BeautifulSoup 抓取位于 here 的股票代码。目前,我尝试了以下方法:
import urllib
import BeautifulSoup
import re
url = r'https://investor.vanguard.com/mutual-funds/vanguard-mutual-funds-list'
html = urllib.urlopen(url).read()
soup = BeautifulSoup.BeautifulSoup(html)
table = soup.findAll('td', attrs = {'class': re.compile(r'\bticker left\b')})
然而,这并没有给我任何东西。有人能解释一下为什么我不能用这个class 属性获得所有td 标签吗? html 会让人认为这是可能的,而且相对轻松。例如:
<td class="ticker left">VUSXX </td>
谢谢。
【问题讨论】:
标签: python beautifulsoup screen-scraping