当前位置: 首页 > news >正文

网站制作费用低/太原百度推广开户

网站制作费用低,太原百度推广开户,化工外贸网站建设,网站设计公司成都Python爬虫系列之微信小程序云函数、sessionid、小程序code、支付算法 为维护网络绿色健康发展,代码仅供学习交流,请勿用于非法用途,如有疑问,请点击这里与我交流 直接上代码 wxSpider.py # -*- coding:utf-8 -*- import reques…

Python爬虫系列之微信小程序云函数、sessionid、小程序code、支付算法

为维护网络绿色健康发展,代码仅供学习交流,请勿用于非法用途,如有疑问,请点击这里与我交流

直接上代码

wxSpider.py

# -*- coding:utf-8 -*-
import requests
import time
import json
import matplotlib.pyplot as plt
import base64
import skimage.iohost = "http://***.***.**.**"
port = "1029"
retry = 3
timeout = 30def getHtml(url):for i in range(retry):try:resp = requests.get(url, timeout=timeout)return resp.json()except Exception as e:passdef postHtml(url, data):for i in range(retry):try:resp = requests.post(url, data=json.dumps(data), headers={"content-type": "application/json"}, timeout=timeout)return resp.json()except Exception as e:passdef gethwnd(accountId):'''检测登录窗口句柄状态loginhwnd=登陆窗口句柄  或  mainhwnd=主窗口句柄  登陆句柄>0说明处于未登陆状态或者是首次登陆正在初始化, 主句柄>0说明登陆成功,初始化完毕,可以调用其他功能了:param accountId::return:'''url = host + ":" + port + "/api/Gethwnd"data = {"accountId": accountId}for i in range(retry):res = postHtml(url, data)try:keys = list(res.keys())if "loginhwnd" in keys and "mainhwnd" in keys:return True, resexcept Exception as e:passtime.sleep(15)return False, Nonedef openWeChat():'''启动微信:return:'''url = host + ":" + port + "/api/OpenWeChat"res = getHtml(url)try:return res['accountId']except Exception as e:passdef showQrcode(base64_str, accountId):'''显示登录二维码:param base64_str::param accountId::return:'''if isinstance(base64_str, bytes):base64_str = base64_str.decode("utf-8")imgdata = base64.b64decode(base64_str)img = skimage.io.imread(imgdata, plugin='imageio')plt.imshow(img)plt.ion()startTs = int(time.time())loginStatus = Falsewhile True:try:plt.pause(2)except Exception as e:passstatus, loginMap = gethwnd(accountId)if status and int(loginMap['mainhwnd']) > 0:loginStatus = Truebreakelse:print("请扫描登录二维码!")time.sleep(2)if int(time.time()) - startTs >= 180:breaktry:plt.close()except Exception as e:passreturn loginStatusdef getLoginQrcode(accountId):'''获取登录二维码:param accountId::return:'''url = host + ":" + port + "/api/GetLoginQrCode"data = {"accountId": int(accountId)}for i in range(retry):try:res = postHtml(url, data)print(res)return res['QrImgDataBase64']except Exception as e:passdef getJsCode(accountId, appid):'''获取小程序code:param accountId::param appid: 目标小程序appid:return:'''url = host + ":" + port + "/api/JsLogin"data = {"accountId": accountId, "appid": appid}for i in range(retry):try:res = postHtml(url, data)print(res)returnexcept Exception as e:passdef main():'''整体流程:return:'''appid = "wxa9795213dd51a4b1"accountId = openWeChat()print("本次测试的accountId为:" + str(accountId) + " 如若需要测试,请复制该值或缓存该值直接进行测试,避免二次登录浪费资源!")status, loginMap = gethwnd(accountId)if status:qrImgDataBase64 = getLoginQrcode(accountId)loginStatus = showQrcode(qrImgDataBase64, accountId)if loginStatus:print("登录成功!")getJsCode(accountId, appid)else:print("登录超时!")if __name__ == '__main__':'''微信windows pc协议'''# 整体流程测试main()# 单次流程测试# 这个值为整体流程登录成功后获取到的,注释main方法的调用流程,单独测试以下流程!!!exit(0)accountId = 1280appid = "wxa9795213dd51a4b1"getJsCode(accountId, appid)

技术交流微信:walei5201314
QQ:804682557

http://www.jmfq.cn/news/4768903.html

相关文章:

  • 为公益组织做网站/网络视频营销平台
  • 网站设计示例/南昌seo推广
  • 做兼职的网站有哪些工作/微博指数
  • 某公司网站源码/西安百度seo推广
  • 网站建设的需求和目的/今天特大军事新闻
  • 做视频网站注意什么问题/温州网站快速排名
  • 优秀的网站建设推荐/外贸接单十大网站
  • 暖色调网站/windows优化大师怎么使用
  • 做网站主页效果图/今天最新的新闻
  • 科技网站制作案例/百度网站怎么申请注册
  • app下载平台哪个好/上海优化营商环境
  • 海曙区建设局网站/如何开发一个软件平台
  • 网站建设及网络推广/seo泛目录培训
  • wordpress 耗内存/厦门seo排名
  • 做网站用什么格式做好/全网营销系统是干什么的
  • 30岁转行做网站设计/学网络营销好就业吗
  • b2b网站代表及网站网址是什么/网站优化策略分析
  • 咸阳市住房和城乡建设规划局网站/搜索引擎的工作原理是什么
  • 前端asp网站开发/数据分析软件
  • 婚纱设计网站首页/360营销推广
  • 东莞工程网站建设/万网创始人
  • 深圳网站建设 手机网站建设/广告营销留电话网站
  • 南宁网站空间/seo课堂
  • 潍坊做网站潍坊做网站/昆明seo工资
  • 中山做网站做的好的公司/华为手机业务最新消息
  • 社会题目可以在哪些网站上做/怎样看网页的友情链接
  • 动态网站建设常见的4种技术/东莞企业推广网站制作
  • wordpress 适合做什么网站/广告推广营销网站
  • 如何浏览香港网站/北京网站优化平台
  • 网站做乘法表/职业技术培训