5.Requests【接口请求】requests模拟发送get请求

一、前言

在前面的课程中我们讲了fiddler的使用,其实对应接口自动化来说,只需要知道怎么通过inspectors页签获取接口信息即可,关于fiddler的其他使用在接口测试中才会使用。

现在,我们已经可以拿到抓取的接口数据了,有了数据就可以模拟请求了,怎么才能模拟请求呢?python中requests模块帮我们解决了这一问题。本节中将对模拟发送get请求做详细讲解。

二、学习目标

1.简单的get请求

三、知识点

1.【简单的get请求】

源码:

def get(url, params=None, **kwargs):
    r"""Sends a GET request.

    :param url: URL for the new :class:`Request` object.
    :param params: (optional) Dictionary, list of tuples or bytes to send
        in the query string for the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :return: :class:`Response <Response>` object
    :rtype: requests.Response
    """

    kwargs.setdefault('allow_redirects', True)
    return request('get', url, params=params, **kwargs)
posted @ 2023-01-17 10:06  测开星辰  阅读(204)  评论(0编辑  收藏  举报