【发布时间】:2015-05-04 08:39:58
【问题描述】:
我有一个大约 100,000 个链接的列表,我想检查其 HTTP 响应代码。以编程方式执行此检查的最佳方法可能是什么?
我正在考虑使用以下 Python 代码:
import requests
try:
for x in range(0, 100000):
r = requests.head(''.join(["http://stackoverflow.com/", str(x)]))
# They'll actually be read from a file, and aren't sequential
print r.status_code
except requests.ConnectionError:
print "failed to connect"
.. 但我没有意识到一次检查如此大量的 URL 的潜在副作用。想法?
【问题讨论】:
-
找到了here 对完全相同的问题的答案!
标签: python http-headers