首页 > 编程语言 > 详细

python3使用urllib获取set-cookies

时间:2018-05-10 10:48:32      阅读:1962      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python  
# encoding: utf-8  
import urllib.request
from collections import defaultdict
response=urllib.request.urlopen("https://twitter.com/login")
headerstr=response.getheaders()
d = defaultdict(list)
for k, v in headerstr:
    if "set-cookie" in k:
        d[k].append(v)
print(d.items())

  上面只是为了做一个 列表 元组转字典的练习,下面才是开始

#!/usr/bin/env python  
# encoding: utf-8  
import urllib.request
from collections import defaultdict
response=urllib.request.urlopen("https://twitter.com/login")
headerstr=response.getheader("set-cookie")
print(headerstr)

  

python3使用urllib获取set-cookies

原文:https://www.cnblogs.com/c-x-a/p/9017885.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!