python脚本 ——二维码链接获取

复制代码
import requests
import json

import pymysql



code = input("请输入id:")
#print(code)
code1 = (repr(code))
#print(code1)
#通过调接口生成加密后code
url = "http://XXX/generateId"

params = {
    "List": code

}
headers = {'content-type': "application/json", "Label": "S"}
r = requests.post(url, data=json.dumps(params), headers=headers)

#print(r.text)

#获取上个步骤的加密code
connection = pymysql.connect(host="base", user="A", password="V", db="C", port=3306, charset='utf8')
cur = connection.cursor()



sql = "select crypt from C t where t.code = %s" %(code1)
#print(sql)
try:
    cur.execute(sql)
    result = cur.fetchall()


except:
    print('Error:unable to fetch data')


#print(result)
cryptcode = result[0]
#print(cryptcode)
results = "https://XXX&Id=%s"%(code)+"&Idcrypt=%s"%(cryptcode)
print("ID二维码生成链接:%s \n"%(results))

connection.close()
input('press enter to exit!')
相关推荐
小珑也要变强22 分钟前
队列基础概念
c语言·开发语言·数据结构·物联网
AI原吾3 小时前
掌握Python-uinput:打造你的输入设备控制大师
开发语言·python·apython-uinput
机器视觉知识推荐、就业指导3 小时前
Qt/C++事件过滤器与控件响应重写的使用、场景的不同
开发语言·数据库·c++·qt
毕设木哥3 小时前
25届计算机专业毕设选题推荐-基于python的二手电子设备交易平台【源码+文档+讲解】
开发语言·python·计算机·django·毕业设计·课程设计·毕设
珞瑜·3 小时前
Matlab R2024B软件安装教程
开发语言·matlab
weixin_455446173 小时前
Python学习的主要知识框架
开发语言·python·学习
孤寂大仙v3 小时前
【C++】STL----list常见用法
开发语言·c++·list
D11_3 小时前
Pandas缺失值处理
python·机器学习·数据分析·numpy·pandas
花生了什么树~.4 小时前
python基础知识(四)--if语句,for\while循环
python
她似晚风般温柔7894 小时前
Uniapp + Vue3 + Vite +Uview + Pinia 分商家实现购物车功能(最新附源码保姆级)
开发语言·javascript·uni-app