-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加自定义头后不能运行,不添加自定义头会被封 #5
Comments
不能运行,指的是会报错吗?贴报错信息看一下 |
直接就没显示也没报错,用你的带头的列子也是一样,直接没一点内容输出,也没报错,我用的是py3.7 |
没有报错就是没问题。没有输出很有可能是目标网站还做了其他的验证,再检查一下。 |
Traceback (most recent call last): |
这个错误源自于 asyncio 的源码,错误类型是 OSError,要想找到根本原因,你可能需要断点进入到源码中。但看文件名 gzip.py,我猜应该跟你传输的消息有关,也许是 Frames。这里我也没能给出具体的解决办法,只能为你提供查找线索的思路 |
import asyncio
import logging
from datetime import datetime
from aiowebsocket.converses import AioWebSocket
async def startup(uri,problem):
header=[
'GET wss://www.hfwh.top/ HTTP/1.1',
'Host: www.hfwh.top',
'Origin: https://www.woxunbudao.cn',
'Upgrade: websocket',
'Sec-WebSocket-Version: 13',
'Connection: Upgrade',
'Sec-WebSocket-Accept: g+8vNmGT8HaLHnj3QcQ/+0Nr5rM=',
]
async with AioWebSocket(uri,headers=header) as aws:
converse = aws.manipulator
Problem=problem
message = '{"type":1,"chars":"'+Problem+'"}'
print(message)
await converse.send(message)#发送数据
print('Client send: {message} \n'.format(message=Problem))
mes = await converse.receive()#接收数据
print('Client receive: {rec} \n'.format(rec=mes))
return mes
if name=='main':
remote='wss://www.hfwh.top/'
problem='科举中"殿试"的主考官是'
print(problem)
print(remote)
try:
asyncio.get_event_loop().run_until_complete(startup(remote,problem))
except KeyboardInterrupt as exc:
logging.info('Quit.')
The text was updated successfully, but these errors were encountered: