-
Notifications
You must be signed in to change notification settings - Fork 6
发送二维码不显示的解决方案 #129
Comments
还是报错,下面是报错信息 DevTools listening on ws://127.0.0.1:51000/devtools/browser/003161e3-0381-44c0-8f89-18fa6ffd3188
|
这是因为你没获取到二维码图片,所以没法解析二维码,发送信息就是空的,自己排查一下为啥没获取到二维码信息吧 |
|
请问大佬,docker版去哪儿修改dingding.py…… |
@dvdrm docker版请参考TechXueXi/TechXueXi#143 |
dingding.py的开头加上
import re
import base64
from io import BytesIO
from pyzbar.pyzbar import decode
from PIL import Image
def base64_to_image(base64_str, image_path=None):
base64_data = re.sub('^data:image/.+;base64,', '', base64_str)
byte_data = base64.b64decode(base64_data)
image_data = BytesIO(byte_data)
img = Image.open(image_data)
if image_path:
img.save(image_path)
return img
后面的def改成
def ddmsgsend(self, msgurl):
import requests, json # 导入依赖库
img=base64_to_image(msgurl)
barcodes = decode(img)
for barcode in barcodes:
url = barcode.data.decode("utf-8")
headers = {"Content-Type": "application/json ; charset=utf-8"} # 定义数据类型
data = {
"text": {
"content": url,
},
"msgtype": "text"
}
res = requests.post(self.get_url(), data=json.dumps(data), headers=headers)
#发送post请求
print(res.text)
最后收到的链接就是登陆链接,复制到学习强国里面发给自己,然后打开链接就行
The text was updated successfully, but these errors were encountered: