Request之get请求

#f发送带有get请求的request请求
import requests
response = requests.get(“https://blog.csdn.net/doulihang/article/details/83041155”,params=None)
print(response.status_code)
print(response.text)
print(“响应头信息:”+str(response.headers))
print(“打印出请求的cookie:”,response.cookies)
import requests

#定义方式使用request模块
import requests
def get_methend(url,prames):
i = requests.get(url,prames)
x= i.status_code
print(x)
get_methend(url= ‘https://tieba.baidu.com/f’,prames={‘kw’:‘李毅’,‘fr’’:“ala0”,"tol’:‘5’})

post方法同理:
def post(url, data=None, json=None, **kwargs):
r"""Sends a POST request.

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

return request('post', url, data=data, json=json, **kwargs)

猜你喜欢

转载自blog.csdn.net/HAHH404/article/details/106524207