Python中经常提示没有被定义是什么问题?

sword_of_justice000 sword_of_justice000 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
比如这个代码:
host,port=='www.xmu.edu.cn',80
msg_head={
'Host':host,
'Connection':'closed',
'Accept':'*/*',
'User-Agent':
r'Mozilla/5.0(Windows NT6.1;WOW64)AppleWebkit/537.36(KHTML,like Gecko)chrome/33.0.1750.154 Safari/537.36'
}
msg='Get/HTTP/1.1\r\n'+'\r\n'.join([':'.join(i)for i in msg_head.items()])+'\r\n\r\n'

import socket
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((host,port))
sock.connect(msg.encode())
resp=sock.recv(4096)

length,html=parse(resp)
while length>len(html):
html+=sock.recv(4096)
open ('resp.txt','web').write(html)
sock.close()
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
sword_of_justice000
脚本语言 37,738 成员 34,208 内容