使用python时出错

2024-06-01 00:37:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我是HTML解析器的新手。我实际上是在用url(http://www.quora.com/How-many-internships-are-necessary-for-a-B-Tech-student)解析网页的源代码。我在想答案。你知道吗

我试过以下方法:

import urllib2
from bs4 import BeautifulSoup

q = urllib2.urlopen(url)
soup = BeautifulSoup(q)
divs = soup.find_all('div',class_='answer_count')

但我把“divs”列为空。为什么会这样?我错在哪里?如何实现它以得到“2个答案”的结果?你知道吗


Tags: 答案importcomhttp解析器urlhtmlwww