zoukankan      html  css  js  c++  java
  • python 自定义request模块调试

    1. 定义
    
    import requests
    import logging
    
    # These two lines enable debugging at httplib level (requests->urllib3->http.client)
    # You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
    # The only thing missing will be the response.body which is not logged.
    try:
        import http.client as http_client
    except ImportError:
        # Python 2
        import httplib as http_client
    http_client.HTTPConnection.debuglevel = 1
    
    # You must initialize logging, otherwise you'll not see debug output.
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True
    
    
    1. 使用
    import amizeLib.requests_debug
    
    login_url = "https://passport.jd.com/uc/loginService"
    # url的参数
    payload = {
        'url': 'url1',
    }
    # post的参数
    data =dict()
    data['post'] = 'post1'
    # http头部
    headers = {
        'User-Agent': 'user_agent',
    }
    
    requests.post('https://httpbin.org/headers',data=data, headers=headers, params=payload)
    
    
  • 相关阅读:
    js 脚本学习 索引
    nodejs 学习索引
    oracle 学习 笔记
    githut 的 管理 使用
    sublime text 插件记录
    web 学习 相关索引
    wpf 自定义 无边框 窗体 resize 实现
    vs 效率工具
    ANDROID开发实用小工具
    iOS开发之Core Animation
  • 原文地址:https://www.cnblogs.com/amize/p/13767858.html
Copyright © 2011-2022 走看看