【发布时间】:2016-01-27 16:07:13
【问题描述】:
我正在使用 Python 3.5 开发网络爬虫。使用请求和 Beautifulsoup4。我正在尝试获取论坛首页上所有主题的链接。并将它们添加到列表中。
我有 2 个问题:
1) 不确定如何使用 beautifulsoup 获取链接,我无法进入链接本身,只有 div 2) Beautifulsoup 似乎只返回了几个主题,而不是全部。
def getTopics():
topics = []
url = 'http://forum.jogos.uol.com.br/pc_f_40'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, 'html.parser')
for link in soup.select('[class="topicos"]'):
a = link.find_all('a href')
print (a)
getTopics()
【问题讨论】:
标签: python python-3.x beautifulsoup web-crawler html-parsing