通过ip批量反查域名,以及查权重
Posted Ocean:)
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过ip批量反查域名,以及查权重相关的知识,希望对你有一定的参考价值。
# 通过ip地址反查域名
import json
import requests
from lxml import etree
# 查询网址https://site.ip138.com/
site = "https://site.ip138.com/"
# 查权重网址,通过爱站api查询
checkWeightSite = "https://apistore.aizhan.com/baidurank/siteinfos/"
priKey = "803ff5bd5f63a269189291a2dd" # 替换为自己的
WeightUrl = checkWeightSite + priKey + "?domains="
# 实例:https://apistore.aizhan.com/baidurank/siteinfos/[私钥]?domains=
headers = {
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.8',
'Cache-Control': 'max-age=0',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/48.0.2564.116 Safari/537.36',
'Connection': 'keep-alive',
'Referer': 'http://www.baidu.com/'
}
# 查域名
def checkDomain(ip):
checkUrl = site + ip
resp = requests.get(checkUrl, headers = headers)
selector = etree.HTML(resp.text)
content = selector.xpath('//span[@class]/../a/text()')
return content[0],ip
# 查域名百度权重
def checkWeight(domain):
url = WeightUrl + domain
print(url)
resp = requests.get(url, headers = headers)
data = json.loads(resp.text)
print(data)
# # 百度权重
# pc_br = data.
# # 百度移动权重
# m_br =
# print()
if __name__ == '__main__':
f = open('url.txt')
for line in f:
line = line.strip()
try:
domain, ip = checkDomain(line)
print('ip' + ip , 'domain : ' + domain)
# checkWeight(domain) 查权重需要将此打开
except:
pass
使用
爱站查权重的api提前测试好再使用,不是很好用~~~
以上是关于通过ip批量反查域名,以及查权重的主要内容,如果未能解决你的问题,请参考以下文章