【Python】批量检测百度权重

挖洞过程中收集了站点后,我一般习惯查看站点的百度权重值,为了方便,写了一个简单的脚本,

至于结果如何显示,看个人需求吧,我这里只是简单的列一下,脚本如下:

#coding:utf-8

import re
import sys
import urllib2
import linecache

url="https://www.aizhan.com/cha/%s/"

headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"}

try:
    file=sys.argv[1]
    for line in linecache.getlines(file):
        line1=line.replace('https://','')
        lines=line1.replace('http://','').split('/')[0]
        #print lines
        urls= url % lines
        req=urllib2.Request(urls,headers=headers)
        resp=urllib2.urlopen(req,timeout=5).read()
        #print resp
        regex=re.compile(r'/br/.+\.png').findall(resp)
        #print regex
        br=regex[0].strip('/br/').strip('.png')
        #print br        
        print lines+'的百度权重为: '+br
        with open('data.txt','a') as fw:
                fw.write(lines+' 的百度权重为: '+br+'\n')
except Exception,e:
    print e

执行结果截图:

 

转载于:https://www.cnblogs.com/peterpan0707007/p/8806325.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值