【发布时间】:2014-03-03 05:50:58
【问题描述】:
我正在尝试从网页中提取标题和标题,但我只得到一个元素。
from BeautifulSoup import BeautifulSoup
import urllib2
url = urllib2.urlopen("http://timesofindia.indiatimes.com/")
content = url.read()
patFinderTitle = re.compile('')
listIterator = []
listIterator[:] = range(2,16)
soup2 = BeautifulSoup(content)
soup2.findAll("title")
print soup2.findAll("h1")
for i in soup2.findAll("title"):
print titleSoup[i]
print "\n"
我在 for 循环中遇到错误,即。
TypeError: list indices must be integers, not Declaration
【问题讨论】:
-
titleSoup是在哪里定义的?
标签: python python-3.x beautifulsoup ipython-notebook