python 批量获取http状态码

海外翻墙免费加速器[入口]

脚本作用:批量获取http状态码可以检测出有异常情况的页面,从而找到问题页面,寻找原因或者删除死链等。

python获取http状态码脚本如下:

#coding:utf-8
#author:www.chenhaifei.com
import requests #打开
import time,random #控制时间
import sys  #专门乱码的
reload(sys)
sys.setdefaultencoding(‘utf-8’)
headers={
‘User-Agent’:’Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36′,
}
url=’http://www.chenhaifei.com/’ ##检测的url
cont = requests.get(url,allow_redirects = False).status_code ##allow_redirects = False不检测跳转后的状态码
print cont
time.sleep(0.5)

未经允许不得转载:陈海飞博客 » python 批量获取http状态码

分享到:更多 ()

海外翻墙免费加速器[入口]