zoukankan      html  css  js  c++  java
  • 获取微信二维码

    获取微信二维码

    微信登陆页面地址:

    path('webChat/',views.webchat,name="webchat"),
    

    1、找出二维码的地址:

    2、获取二维码地址的另一个值:

    3、获取微信二维码的代码如下

    3.1 前端页面templates/webchat.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Wechat</title>
    </head>
    <body>
        <div style=" 300px;margin: 0 auto;">
            <img id="qcode"  style=" 300px;height: 300px;" src="https://login.weixin.qq.com/qrcode/{{code}}"/>
        </div>
    </body>
    </html>
    

    3.2 后端请求获取二维码另一个值uuid,web/views.py

    
    # Create your views here.
    from django.shortcuts import render
    from django.shortcuts import HttpResponse
    import requests
    import re
    import time
    VERIFY_TIME =None
    verifi_uuid =None
    
    def webchat(request):
        #获取验证码的url
        verificode_url = "https://login.wx.qq.com/jslogin?appid=wx782c26e4c19acffb&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage&fun=new&lang=zh_CN&_={0}"
        verifi_reponse =requests.get(url=verificode_url)
        #print(verifi_reponse.text)
        #时间戳
        global VERIFY_TIME
        VERIFY_TIME = str(time.time())
        verificode_url.format(VERIFY_TIME)
        global verifi_uuid
        #匹配二维码另一个值
        verifi_uuid=re.findall('uuid = "(.*)";',verifi_reponse.text)[0]
        return render(request,"webchat.html",{"code":verifi_uuid,
                                              })
    
  • 相关阅读:
    f5版本升级
    f5申请并激活License
    f5时间设置
    f5 SNMP配置
    f5 Syslog管理
    f5单台安装配置
    f5负载均衡算法
    f5 Seldom used
    f5售后查询
    f5基本介绍
  • 原文地址:https://www.cnblogs.com/venvive/p/11564811.html
Copyright © 2011-2022 走看看