Python3 requests模块

python requests模块

import requests

def test():
    url = 'http://erge1998.cn'
    # 发起get请求,并且返回结果
    # 将请求到的内容赋值给rsp
    rsp = requests.get(url)
    # 此时的rsp属于一个类,是一个response类型
    print(type(rsp))
    # rsp 属于一个类,就可以调用的.text方法
    print(rsp.text)
    # 查看返回码
    print(rsp.status_code)

if __name__ == '__main__':
    test()
原文地址:https://www.cnblogs.com/laod/p/13092140.html