zoukankan      html  css  js  c++  java
  • python+requests+new——get请求各种情况

    import requests

    urls = 'http://httpbin.org/get'

    a='k1'
    b='v1'
    c='k2'
    d='v2'


    response = requests.get(url=urls, params={a: b,c:d})
    print(response.status_code)
    print(response.url)

    执行结果:

    200
    http://httpbin.org/get?k1=v1&k2=v2

    =======================================================================================================

    import requests
    
    urls = 'http://httpbin.org/get'
    
    payload001 = {'k1':'v1','k2':'v2'}
    
    response = requests.get(url=urls, params=payload001)
    print(response.status_code)
    print(response.url)

    执行结果:

    200
    http://httpbin.org/get?k1=v1&k2=v2

    =====================================================================================================

    import requests
    
    urls = 'http://httpbin.org/get'
    
    payload002 = {'key1': 'value1', 'key2': ['value2', 'value3']}
    
    response = requests.get(url=urls, params=payload002)
    print(response.status_code)
    print(response.url)

    执行结果:

    200
    http://httpbin.org/get?key1=value1&key2=value2&key2=value3

    ========================================================================================

    定制请求体:

    urls = 'https://api.github.com/some/endpoint'
    payload002 = {'key1': 'value1', 'key2': ['value2', 'value3']}
    headersl = {'user-agent': 'my-app/0.0.1'}
    
    response = requests.get(url=urls, headers=headersl, params=payload002)

    ========================================================================================

  • 相关阅读:
    数据源ObjectDataSource的数据访问类的编写
    ASP.NET网页文本编辑器的使用
    装饰模式
    策略模式
    代理模式
    备份、还原数据库
    简单工厂和工厂模式
    ASP.NET上传多个文件
    数据库访问类的编写
    UVA 11069 A Graph Problem
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12662097.html
Copyright © 2011-2022 走看看