【发布时间】:2018-06-23 03:38:48
【问题描述】:
我知道这个问题的变体已被问过一百次,但我无法找到适合我情况的答案。
我是 python 新手,我正在尝试使用以下代码:
import urllib
import requests
from bs4 import BeautifulSoup
theurl = "https://twitter.com"
thepage = requests.get(theurl)
soup = BeautifulSoup(thepage, "html.parser")
print(soup.title)
因此我收到以下错误:
Traceback (most recent call last): File
"/Users/username/PycharmProjects/WebScraper2.0/web.py", line 8, in
<module>
soup = BeautifulSoup(thepage, "html.parser") File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/bs4/__init__.py",
line 192, in __init__
elif len(markup) <= 256 and ( TypeError: object of type 'Response' has no len()
这里有什么问题?我仍在尝试熟悉错误代码,据我所知,这个错误代码似乎很笼统。有人愿意帮助我并解释问题所在吗?从我看到的例子来看,这应该可以工作......我错过了什么?
【问题讨论】:
标签: python beautifulsoup python-requests