zoukankan      html  css  js  c++  java
  • requests库入门-3-requests小demo

    1.用Requests发送百度请求

    新建一个requests_test.py文件,输入如下内容。

    import requests

    #请求百度网页
    response = requests.get("https://www.baidu.com", data=None,timeout=10)
    print(response.headers)

    #打印内容如下

    {'Cache-Control': 'private, no-cache, no-store, proxy-revalidate, no-transform',
    'Connection': 'Keep-Alive',
    'Content-Encoding': 'gzip',
    'Content-Type': 'text/html',
    'Date': 'Wed, 23 Aug 2017 14:51:05 GMT',
    'Last-Modified': 'Mon, 23 Jan 2017 13:23:51 GMT',
    'Pragma': 'no-cache',
    'Server': 'bfe/1.0.8.18',
    'Set-Cookie': 'BDORZ=27315; max-age=86400; domain=.baidu.com; path=/',
    'Transfer-Encoding': 'chunked'
    }

  • 相关阅读:
    文件进阶
    文件及文件操作
    字符编码
    集合
    数据类型之字典
    数据类型之列表,元组
    数据类型之数字,字符串
    for 循环语句
    while 循环语句
    深浅拷贝
  • 原文地址:https://www.cnblogs.com/weihanhan/p/14669904.html
Copyright © 2011-2022 走看看