本文目錄一覽:
python爬蟲做qq機器人的問題
我覺得是可能是因為沒帶cookie造成的吧?順便說一下,ptqrtoken是「cookie裡面的qrsig的hash33」,代碼在github的justko/qzonelib,雖然寫的不好,給我加個星星吧:-)
defcheck_qrcode(self):
qrsig=None
foriinself.qq_cookie:
ifi.name=='qrsig':
qrsig=i.value
break
ifqrsigisNone:
print("QR_Code識別碼沒有找到,需要重新下載")
raiseRuntimeError
req=urllib.request.Request(
url=""
"?u1=https%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone"
"ptqrtoken="+str(QQ.__hash33(qrsig))+
"ptredirect=0h=1t=1g=1from_ui=1ptlang=2052"
"action=0-0-1509338784922"
"js_ver=10231js_type=1login_sig=pt_uistyle=40aid=549000912daid=5"
)
res=self.opener.open(req).read().decode()
result=re.match("ptuiCB\('([^']*)','[^']*','([^']*)','[^']*','([^']*)','(.*)'\)",res)
code=result.group(1)
success_url=result.group(2)
info=result.group(3)
username=result.group(4)
returncode,success_url,info,usernamedefcheck_qrcode(self):
iOS可以做QQbot嗎
不可以。
qqbot是一個python語言的基於smartqq協議的python庫,他可以實現監聽qq聊天,發送特定qq消息,從而能製作一個自己的qq機器人。不能ios下載。
ios很多軟件都不能下載,沒有權限的。
利用python + qqbot + 聚合數據api 實現qq智能聊天機器人
from qqbot import QQBotSlot as qqbotslot,RunBot
from random import randint
@qqbotslot
def onQQMessage(bot, contact, member, content):
#在這裡過濾過來的輸入, content的內容是監聽qq上所有的輸入
# 當群里有人@你的時候 傳入過來的會被轉化為[@ME]
# 所以使用 @ME 來過濾其他人在群裡面at你
if '@ME' in content:
#四個參數的詳細
#bot : QQBot 對象,提供 List/SendTo/Stop/Restart 四個接口,詳見本文檔第五節
#contact : QContact 對象,消息的發送者,具有 ctype/qq/uin/nick/mark/card/name 屬性,這些屬性都是 str 對象
#member : QContact 對象,僅當本消息為 群或討論組 消息時有效,代表實際發消息的成員
#content : str 對象,消息內容
bot.SendTo(contact,'@'+ member.name+ " 哈哈 ")
#這裡是因為部分群裡面的at無法轉化為[@ME]所以自己過濾at自己的內容
elif '@' in content and '光' in content:
bot.SendTo(contact,'@'+ member.name+ " 哈哈 ")
RunBot()“`
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/154651.html