我已尝试以下代码来提取页面网址。
from bs4 import BeautifulSoup
import urllib3
http = urllib3.PoolManager()
url = 'http://www.thefamouspeople.com/singers.php'
response = http.request('GET', url)
html = response.read()
soup = BeautifulSoup(html)
print soup.prettify()
但是,我想知道它给出空白输出。我错过了什么吗?
答案 0 :(得分:0)
您应该尝试在html = str(html)
之后添加html = response.read()
,因为html = response.read()
会返回字节。