【发布时间】:2014-05-09 17:21:28
【问题描述】:
我收到此错误:
NameError: name 'htmltext' is not defined
来源于以下代码:
from bs4 import BeautifulSoup
import urllib
import urllib.parse
url = "http://nytimes.com"
urls = [url]
visited = [url]
while len(urls) > 0:
try:
htmltext = urllib.urlopen(urls[0]).read()
except:
print(urls[0])
soup = BeautifulSoup(htmltext)
urls.pop(0)
print(soup.findAll('a',href = true))
【问题讨论】:
标签: python python-3.x beautifulsoup