我想要从 urllib
python 库中获得相当于 urlopen
的东西来从网络获取数据,
urlopen
似乎无法在 google 或 youtube 等网站上运行,可能是由于 header 不正确,
那么我可以使用其他基于 python 的内容 getter 吗?
最佳答案
这是一个使用 urllib2
获取网页的示例:
import urllib2
response = urllib2.urlopen('http://google.com/')
html = response.read()
示例取自urllib2 documentation .
关于python 库从网站获取内容(http 文本)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22681037/