• python3使用urllib获取set-cookies


    #!/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)
    

      

  • 相关阅读:
    java嵌套循环练习
    java菜鸡循环练习
    Kruskal重构树
    狄利克雷卷积
    莫比乌斯反演
    两道趣题
    树状数组
    多重背包
    SPFA与差分约束
    快速线性筛
  • 原文地址:https://www.cnblogs.com/c-x-a/p/9017885.html
Copyright © 2020-2023  润新知