利用其它平台的实名检查接口查询具体号码
- import os
- import re
- import requests
- import time
- import execjs
- from bs4 import BeautifulSoup
- import calendar
- from enum import Enum
- from goto import with_goto
- import random
- class regstatus(Enum):
- SUCCESS = 1
- EXISTED = 1
- VERIFY = 3
- ERROR = 4
- def idEnd(c_id):
- '''
- c_id #身份证号前17位
- '''
- if isinstance(c_id, str):
- check_code=['1','0','X','9','8','7','6','5','4','3','2'] # 余数对应的校验码
- factor=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2] # 身份证号对应的前17位加权因子
- sum=0
- for i in range(len(c_id)):
- sum=sum int(c_id[i])*factor[i] # 身份证号每一位与对应加权因子相乘并求和
- remainder=divmod(sum,11)[1] # 所得和对11取余数
-
- return check_code[remainder]
- elif isinstance(c_id, int):
- idEnd(str(c_id))
- else:
- print("类型错误")
- return None
- def retStr(s):
- try:
- if s<10:
- return '0' str(s)
- else:
- return str(s)
- except:
- print("输入数字")
- def yue(yea):
- # calendar.isleap(2000) 平年还是闰年
- days = []
- for m in range(1,13):
- dayend = calendar.monthrange(yea, m)
- # print('月',m,dayend)
- #print("月",m,"天",dayend[1])
- for d in range(1,dayend[1]):
- days.append(retStr(m) retStr(d))
- return days
- def main17(c_id):
- '''
- c_id '4113221980****0679'
- return ['411322198012110679']
- '''
- shide = []
- if len(c_id)==18:
- y = c_id[6:10]
- days = yue(int(y))
- for day in days:
- d_id = c_id[:10] day c_id[14:17]
- zuihos = idEnd(d_id)
- if zuihos == str(c_id[-1:]):
-
- shide.append(d_id c_id[-1:] )
- return shide
- else:
- return shide
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- reqsession = requests.session()
-
-
- urljs = 'https://blog.thenobleyou.com/cryptojs-aes.php'
- url = 'http://ptlogin.4399.com/ptlogin/regFrame.do'
- regurl = 'http://ptlogin.4399.com/ptlogin/register.do'
- captchaurl = 'http://ptlogin.4399.com/ptlogin/captcha.do'
- parser = {
- "regMode":'reg_normal',
- "postLoginHandler":'default',
- "bizId":'',
- "redirectUrl":'',
- "displayMode":'popup',
- "css":'',
- "appId":'www_home',
- "gameId":'',
- "noEmail":'false',
- "regIdcard":'false',
- "autoLogin":'true',
- "cid":'',
- "aid":'',
- "ref":'',
- "level":'4',
- "mainDivId":'popup_reg_div',
- "includeFcmInfo":'false',
- "externalLogin":'qq',
- "fcmFakeValidate":'true',
- "expandFcmInput":'true',
- "userNameLabel":'4399用户名',
- "userNameTip":'请输入4399用户名',
- "welcomeTip":'欢迎回到4399',
- "v":str(int(time.time()*1000)),
- }
- headers = {
- 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
- }
- captcha_params = None # 是否有验证码
- jscomplie = None # js加载对象
- username = None # 4339的用户名
- qcccookie = None #企查查cookie
- resjs = reqsession.get(urljs,headers=headers).text
- jscomplie = execjs.compile(resjs)
- def init():
- response = reqsession.get(url,params=parser,headers=headers)
- global jscomplie,username,captcha_params,resjs
-
- btsp = BeautifulSoup(response.text,'html.parser')
-
- username = btsp.findAll('input',{'id':'j-username'})
- for userna in username:
- username = userna.get('value')
- if len(username)==0:
- username = str(random.randint(10000000000,9999999999999999999))
- imgs = btsp.findAll('img',{'id':'captcha'})
-
-
- for img in imgs:
- ons = re.findall("'(.*?)'",img.get('onclick'))
- captchaId = ons[0]
- params = {
- 'captchaId':captchaId
- }
- captcha_params = params
-
-
- def savecatimg():
- captimg = reqsession.get(captchaurl,headers=headers,params = captcha_params)
- fileDir = './456.png'
- with open(fileDir,'wb')as f:
- f.write(captimg.content)
-
- os.startfile(os.getcwd() '\\456.png')
-
- @with_goto
- def main(name,idsheng):
-
- init()
- ids = main17(idsheng)
- for id_,i in zip(ids,range(0,len(ids))):
-
- label.begin
- regdata = {
- "postLoginHandler":'default',
- "displayMode":'popup',
- "bizId":'',
- "appId":'www_home',
- "gameId":'',
- "cid":'',
- "externalLogin":'qq',
- "aid":'',
- "ref":'',
- "css":'',
- "redirectUrl":'',
- "regMode":'reg_normal',
- "sessionId":'',
- "regIdcard":'true',
- "noEmail":'',
- "crossDomainIFrame":'',
- "crossDomainUrl":'',
- "mainDivId":'popup_reg_div',
- "showRegInfo":'true',
- "includeFcmInfo":'false',
- "expandFcmInput":'true',
- "fcmFakeValidate":'false',
- "realnameValidate":'true',
- "userNameLabel":'4399用户名',
- "level":'4',
- "sec":'1',
- "password":jscomplie.call('encryptAES','456789'),
- "passwordveri":jscomplie.call('encryptAES','456789'),
- "realname":jscomplie.call('encryptAES',name),
- "idcard":jscomplie.call('encryptAES',id_),
- "username":username,
- "email":'',
- "reg_eula_agree":'on',
- "autoLogin":'on',
- }
- if captcha_params:
- regdata['sessionId'] = captcha_params['captchaId']
- savecatimg()
-
- regdata['inputCaptcha'] = str(input("请输入你所看到的验证码"))
-
- try:
- res = reqsession.post(regurl,data=regdata,headers=headers)
- except:
- print("网络连接超时")
- exit()
- btsp = BeautifulSoup(res.text,'html.parser')
- msgs = btsp.findAll('div',{'id':'Msg'})
- regstatu = None
- # 注册失败会进入mags
- for msg in msgs:
- if msg.text.strip()=='姓名身份证不匹配':
- print("姓名身份证不匹配 身份id",id_)
- goto.end
- print("结束")
- break
- elif msg.text.strip()=='用户名已被注册':
- print("用户名已被注册")
- regstatu = regstatus.EXISTED
- break
- elif msg.text.strip()=='验证码错误':
- print('验证码输入错误',id_)
- goto.begin
- regstatu = regstatus.VERIFY
- break
- else:
- # 未知错误
-
- print(res.text)
- print('未知错误')
- regstatu = regstatus.ERROR
- break
- perinfos = btsp.findAll('div',{'class':'ptlogin_perinfo'})
- for perinfo in perinfos:
- print(username)
- print(id_)
- print("注册成功")
- regstatu = regstatus.SUCCESS
- break
- if regstatu == regstatus.VERIFY:
- # 需要验证码
- goto.begin
- pass
-
- elif regstatu == regstatus.EXISTED:
- # 用户已存在
- break
- elif regstatu == regstatus.ERROR:
- # 未知错误
- break
- elif regstatu == regstatus.SUCCESS:
- # 注册成功
- break
- label.end
-
- qccids = []
- def qccmain(name,page:int = 1):
-
- qccurl = 'https://www.qcc.com/more_deadbeatlist'
- headers['Cookie'] = qcccookie
- params = {'key':name,'p':page}
- resphtml = requests.get(qccurl,headers=headers,params=params).text
- del headers['Cookie']
- btsp = BeautifulSoup(resphtml,'html.parser')
- idlists = btsp.findAll('span',{'class':'val'})
-
- # currentactive = btsp.findAll('li', {'class': 'current active'})
-
- for idlist,ind in zip(idlists,range(0,len(idlists))):
- if not ind%2:
- qccids.append(idlist.text)
-
- if page == 1:
- print("正在查询...")
- endindex = 2
- endpage = btsp.findAll('a', {'class': 'end'})
- for pa in endpage:
- endindex = int(pa.text)
- for i in range(2,endindex 1):
-
- qccmain(name,i)
-
- def starts():
- global qcccookie
-
- qcccookie = str(input("请输入企查查的Cookie"))
- qccname = str(input("请输入要查询的姓名:"))
- #qccname= '周润发'
- #qccmain(qccname)
- print("共查询到",len(qccids))
- for s_id in qccids:
- main(qccname, s_id)
-
-
-
-
-
- if __name__=="__main__":
-
-
- starts()
-
- #range(1, 5)
复制代码
|