python验证手机号是否注册过微博

首先看一下返回格式:

"code":"100000"表示没注册

"code":"600001"表示已经注册

{"code":"100000","data":{"id":"","state":true,"type":"ok","code":"100000","action":"io","msg":"","iodata":""},"msg":""}
{"code":"600001","data":{"id":"","state":true,"type":"err","code":"600001","action":"io","msg":"该手机号已注册,可<a href="javascript:void(0)" action-type="btn_login">直接登录<\/a>","iodata":""},"msg":""}

上代码:

import requests,time
from urllib import parse
header = {
"Host": "weibo.com",
"Connection": "keep-alive",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "*/*",
"Referer":"https://weibo.com/signup/signup.php",
"Accept-Encoding":"gzip, deflate, br",
"Accept-Language":"zh-CN,zh;q=0.9",
"Cookie": "UOR=cuiqingcai.com,widget.weibo.com,cuiqingcai.com; SINAGLOBAL=4488993145257.228.1526896503332; SCF=AlC33K5qfoC7HrROfBB4mJtN4jIrVfmOXc5lAUlmorulSufEgLxzAoaGm9UpO3hHKasTrfkIe_0LeF5Zd8gRv7M.; SUHB=0nlfv7xtsoHJQt; YF-Ugrow-G0=ad83bc19c1269e709f753b172bddb094; SUB=_2AkMsSHHIf8NxqwJRmP4RzmvkaY9_yQ_EieKaFIATJRMxHRl-yT83qkYgtRB6B8hfJraHaIVDNybz4ulKcpL4rU8_KteM; SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9WFzw.rJdFEwdBoiQG9_E9Hi; login_sid_t=c8537f18996d44a673568d321f8c5072; cross_origin_proto=SSL; YF-V5-G0=16139189c1dbd74e7d073bc6ebfa4935; WBStorage=5548c0baa42e6f3d|undefined; _s_tentry=passport.weibo.com; wb_view_log=1366*7681; __lnkrntdmcvrd=-1; Apache=6358580283442.719.1528102658639; ULV=1528102658655:2:1:1:6358580283442.719.1528102658639:1526896504059; appkey=",
}
url = "https://weibo.com/signup/v5/formcheck?type=mobilesea&zone=0086&value=xxxxxxxxxxx&from=&__rnd="+str(int(time.time())*13)
res = requests.get(url,headers = header).text
res = parse.unquote(res)
print(res.encode('utf-8').decode('unicode_escape'))

xxxxxxxxxxx表示手机号

自己封装一下就可以了。

如果返回值有问题,自己更改一下 Cookie 或者 User-Agent 等。

短时间大量验证,自己准备好ip池。


猜你喜欢

转载自blog.csdn.net/m0_38124502/article/details/80571842
今日推荐