致力于一个自动化搜索几千个google搜索的项目,能够检查是否有“未找到结果”,并输入到一个数组中。你知道吗
使用BeautifulSoup,但我无法从URL导入HTML:
from bs4 import BeautifulSoup
import requests
html = requests.get('www.lifehack.org')
soup = BeautifulSoup(html,'html.parser')
软件包安装得很好,但我发现错误:
MissingSchema Traceback (most recent call last)
<ipython-input-28-8e881302fa25> in <module>
1 from bs4 import BeautifulSoup
2 import requests
----> 3 html = requests.get('www.lifehack.org')
4 soup = BeautifulSoup(html,'html.parser')
C:\Program Files (x86)\Anaconda\lib\site-packages\requests\api.py in get(url, params, **kwargs)
73
74 kwargs.setdefault('allow_redirects', True)
+更多类似的东西
我不知道怎么解决这个问题。我希望能够快速得到的HTML直接进入程序,而不必复制它,并保存在一个本地HTML文件
任何帮助都将不胜感激,谢谢。你知道吗
首先,您应该发布完整的错误消息,如果您只发布了部分错误消息,则无法解决问题。你知道吗
也就是说,有一件事可能会引起问题,那就是你的url需要完全限定。你知道吗
事实上,如果您公布了执行代码时遇到的全部错误,您可能会看到这样的情况,这会给出您的答案:
一旦解决了这个问题,就会遇到另一个问题:
您的
html
变量是一个响应对象,您不能将其直接传递给BeautifulSoup。您希望传递从响应中获得的文本。你知道吗这个故事的寓意是:注意你的错误信息,它们是你的向导。你知道吗
相关问题 更多 >
编程相关推荐