圆月山庄资源网 Design By www.vgjia.com
如下所示:
import urllib import urllib2 import os import time import re import cookielib import xml.dom.minidom import json tip = 0 uuid = '' successUrl = '' skey = '' wxsid = '' wxuin = '' pass_ticket = '' deviceId = 'e000000000000000' imagesPath = os.getcwd() + '/weixin.jpg' BaseRequest = {} base_uri = '' push_uri = '' def getUUID(): global uuid url = 'https://login.weixin.qq.com/jslogin' values = { 'appid':'wx782c26e4c19acffb', 'redirect_uri':'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage', 'fun':'new', 'lang':'zh_CN', '_':int(time.time()) } request = urllib2.Request(url=url, data=urllib.urlencode(values)) response = urllib2.urlopen(request) data = response.read() print data regx = r'window.QRLogin.code = (\d+); window.QRLogin.uuid = "(\S+"' pm = re.search(regx, data) code = pm.group(1) uuid = pm.group(2) print code, uuid if code == '200': return True return False def show2DimensionCode(): global tip url = 'https://login.weixin.qq.com/qrcode/' + uuid values = { 't':'webwx', '_':int(time.time()) } request = urllib2.Request(url=url, data=urllib.urlencode(values)) response = urllib2.urlopen(request) tip = 1 f = open(imagesPath, 'wb') f.write(response.read()) f.close() time.sleep(1) os.system('call %s' % imagesPath) print u'please sacn qcode by your phone'.encode('GBK') def isLoginSucess(): global successUrl, base_uri, push_uri url = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login"(\S+"' pm = re.search(regx, data) pmLogin = re.search(regxLogin, data) code = pm.group(1) if pmLogin != None: successUrl = pmLogin.group(1) + '&fun=new&version=v2' if code == '201': print'Scan QR code successfully!' elif code == '200': print'Logining...' services = [ ('wx2.qq.com', 'webpush2.weixin.qq.com'), ('qq.com', 'webpush.weixin.qq.com'), ('web1.wechat.com', 'webpush1.wechat.com'), ('web2.wechat.com', 'webpush2.wechat.com'), ('wechat.com', 'webpush.wechat.com'), ('web1.wechatapp.com', 'webpush1.wechatapp.com'), ] base_uri = successUrl[:successUrl.rfind('/')] push_uri = base_uri for (searchUrl, pushUrl) in services: if base_uri.find(searchUrl) >= 0: push_uri = 'https://%s/cgi-bin/mmwebwx-bin' % pushUrl break elif code == '408': print'Login Timeout!' return code def webwxnewloginpage(): global successUrl, skey, wxsid, wxuin, pass_ticket, BaseRequest request = urllib2.Request(url=successUrl) response = urllib2.urlopen(request) data = response.read() doc = xml.dom.minidom.parseString(data) root = doc.documentElement for node in root.childNodes: if node.nodeName == 'skey': skey = node.childNodes[0].data elif node.nodeName == 'wxsid': wxsid = node.childNodes[0].data elif node.nodeName == 'wxuin': wxuin = node.childNodes[0].data elif node.nodeName == 'pass_ticket': pass_ticket = node.childNodes[0].data BaseRequest = { 'Uin': wxuin, 'Sid': wxsid, 'Skey': skey, 'DeviceID': deviceId, } def webwxinit(): global skey, pass_ticket, BaseRequest, base_uri url = (base_uri + '/webwxinit?pass_ticket=%s&skey=%s&r=%s' % (pass_ticket, skey, int(time.time()))) params = {'BaseRequest': BaseRequest} headers = {'content-type': 'application/json; charset=UTF-8'} request = urllib2.Request(url=url, data=json.dumps(params), headers=headers) response = urllib2.urlopen(request) data = response.read() print data def webwxgetcontact(): global skey, pass_ticket, base_uri url = (base_uri + '/webwxgetcontact?pass_ticket=%s&skey=%s&r=%s' % (pass_ticket, skey, int(time.time()))) headers = {'content-type': 'application/json; charset=UTF-8'} request = urllib2.Request(url=url, headers=headers) response = urllib2.urlopen(request) data = response.read() print data def main(): cookie = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar())) urllib2.install_opener(cookie) if getUUID() == False: print'Get uuid unsuccessfully!' return None show2DimensionCode() time.sleep(1) while isLoginSucess() != '200': pass webwxnewloginpage() # time.sleep(1) # webwxinit() time.sleep(1) webwxgetcontact() os.remove(imagesPath) print'Login successfully!' if __name__ == '__main__': print'Welcome to use weixin personnal version' print'Please click Enter key to continue......' main()
以上这篇python 获取微信好友列表的方法(微信web)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
标签:
python,微信,好友,列表
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年11月06日
2024年11月06日
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]