首页上一页 1 下一页尾页 3 条记录 1/1页
程序运行成功,但是cookie信息获取不到,有大佬帮忙看看呗
发表在Python图书答疑
2022-03-21
悬赏:2 学分
《Python网络爬虫从入门到实践》第3章 请求模块urllib 55页-0页
是否精华
是
否
版块置顶:
是
否
import urllib.request
import urllib.parse
import http.cookiejar
import json
url='http://site2.rjkflm.com:666/index/index/chklogin.html'
data=bytes(urllib.parse.urlencode({'username': '衡阳烟去五柳伊'
,'password':'740818961016'}),encoding='utf-8')
cookie_file='cookie.txt'
cookie=http.cookiejar.LWPCookieJar(cookie_file)
cookie_processor=urllib.request.HTTPCookieProcessor(cookie)
opener=urllib.request.build_opener(cookie_processor)
response=opener.open(url, data=data)
responses=json.loads(response.read().decode('utf-8'))['msg']
if responses == '登录成功! ':
cookie.save(ignore_discard=True,ignore_expires=True)于2022-03-21 21:24:45编辑

购物车
发表新帖
立即签到









