用Python实现微信域名检测(附python代码)
发布于 3 年前 作者 lei62 4275 次浏览 来自 分享

作为一名程序猿,不能够停留用php和html实现,这次用“人生苦短,我用python”的python来编程,实现微信域名检测,不得不说python是真牛逼!

提取搜索结果的URL

百度搜索结果url提取,按F12到consale端,复制以下代码,回车执行。

var tag=document.getElementsByClassName('r');
 for (var i=0;i<tag.length;i++){
        var a=tag[i].getElementsByTagName("a");
        console.log(a[0].href)
 }

提取的数组,保存到url.txt,放入待检测的链接或域名,一行一个。

import io
import shutil
readPath='python.txt'
writePath='url.txt'
lines_seen=set()
outfiile=io.open(writePath,'a+',encoding='utf-8')
f=io.open(readPath,'r',encoding='utf-8')
for line in f:
    if not len(line):
        continue
    if line not in lines_seen:
        outfiile.write(line)
        lines_seen.add(line)

实现批量检测代码

注意:ok,txt为链接正常,red.txt为链接已被拦截或屏蔽。

#! /usr/bin/env python 域名检测罗晶 免费撸的接口地址:https://dwz.cn/TzLUYNU2
import os,urllib,linecache
import sys
import time
import requests
result = list()
strxx = '"Code":"102"'
html = ''
for y in linecache.updatecache(r'url.txt'):
 try:
 headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
 #response = urllib.urlopen(x) 
 #html = response.read()
 x = 'http://api.new.urlzt.com/api/qq?token=Token值(后台生成获取,后台地址:https://dwz.cn/TzLUYNU2)&url=www.urlzt.com' + y
 response = requests.get(x,headers=headers)
 html = response.text
   time.sleep(3)
   #print x,a
except Exception,e:
    html = ''
    print e
if strxx in html:
    print 'ok:'
    print x
    with open ('ok.txt','a') as f:  
        f.write(y)
else:
    print 'error:'        
    print y
    html = ''
    with open ('red.txt','a') as f:  
        f.write(y)

回到顶部