python3使用urllib获取set-cookies
1 2 3 4 5 6 7 8 9 10 11 | #!/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()) |
上面只是为了做一个 列表 元组转字典的练习,下面才是开始
1 2 3 4 5 6 7 | #!/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) |
本文作者:公众号python学习开发
本文链接:https://www.cnblogs.com/c-x-a/p/9017885.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2017-05-10 python的map/reduce区别
2016-05-10 nodejs的 new String