获取微信二维码

# Create your views here.from django.shortcuts import renderfrom django.shortcuts import HttpResponseimport requestsimport reimport timeVERIFY_TIME =Noneverifi_uuid =Nonedef 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, })
02-12 21:06