【发布时间】:2016-06-27 15:10:37
【问题描述】:
我有这个
from urllib import request
url = "http://www.bbc.co.uk/news/election-us-2016-35791008"
html = request.urlopen(url).read().decode('utf8')
html[:60]
from bs4 import BeautifulSoup
raw = BeautifulSoup(html, 'html.parser').get_text()
raw.find_all('title', limit=1)
print (raw.find_all("title"))
'<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN'
我想使用 BeautifulSoup 提取页面的标题,但出现此错误
Traceback (most recent call last):
File "C:\Users\Passanova\AppData\Local\Programs\Python\Python35-32\test.py", line 8, in <module>
raw.find_all('title', limit=1)
AttributeError: 'str' object has no attribute 'find_all'
请给点建议
【问题讨论】: