是否可以使用 python 获取网页的前几个,比如 1K?
非常感谢!
最佳答案
Requests库允许您在响应进入时对其进行迭代,因此您可以执行如下操作:
import requests
beginning = requests.get('http://example.com/').iter_content(1024).next()
如果您只想要 header ,您始终可以使用 http HEAD 方法:
req = requests.head('http://example.com')
关于python - 是否可以使用 python 获取网页的前几个,比如 1K?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11183371/