应某位2b人士要求,代码如下(未优化,短期完成),麻烦闭住带屎嘴巴。
#coding=GB18030 import urllib.request as ur import urllib.parse as up import time,json cookie=ur.HTTPCookieProcessor() oper=ur.build_opener(cookie) def now(): return str(time.time()*1000)[:-2] user='xxxxxx' passwd='xxx' userurl=r'http://profile.baihe.com/new/BasicInfo.action?oppId=' headers={'User-Agent':'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML,like Gecko) Chrome/17.0.963.79 Safari/535.11'} loginurl=r'http://passport.baihe.com/loginForXs.jsp?txtLoginEMail='+user+r'&txtLoginPwd='+passwd+r'&chkRememberMe=No&time='+now()+r'&_='+now() def nowuser(): return r'http://cityonline.baihe.com/showOnlineList.action?jsoncallback=jsonp'+str(int(now())-500)+r'&_='+now()+r'&hashPhoto=1&gender=0&age=22&age_end=30&city_num=864201&size=25&num=25' def getcon(url,data=None): print(url,'\n\n') request = ur.Request(url,data,headers=headers) url = oper.open(request) page=url.read().decode('GB18030','ignore') return page def douser(getdata): getdata=getdata[getdata.find('(')+1:getdata.rfind(')')] d=json.loads(getdata) for i in d: a=d.get(i) if isinstance(a,dict): print('正在访问:',a.get('city'),a.get('degree'),a.get('age'),a.get('height'),a.get('nick'),a.get('userid')) getcon(userurl+a.get('userid')) getcon(loginurl) while True: try: d=getcon(nowuser()) douser(d) except: pass原文链接:https://www.f2er.com/json/290644.html