python3+requests:get/post请求

时间:2023-02-26 20:47:53

1.get请求

(1)没有请求参数类型

 response = requests.get(url='')
print(response.text)

(2)有请求参数的类型(键值对形式表示参数)

 response = requests.get(url='',params={'key1':'value1','key2':'value2'})
print(response.text)

(3)有请求头(键值对形式表示请求头)

 response = requests.get(url='',headers={'key1':'value1'})
print(response.text)

2.post请求

(1)请求正文是application/x-www-form-urlencoded

 requests.post(url='',data={'key1':'value1','key2':'value2'},headers={'Content-Type':'application/x-www-form-urlencoded'})

(2)请求正文是multipart/form-data

 requests.post(url='',data={'key1':'value1','key2':'value2'},headers={'Content-Type':'multipart/form-data'})

(3)请求正文是raw

传入xml格式文本
 requests.post(url='',data='<?xml  ?>',headers={'Content-Type':'text/xml'})
传入json格式文本
 requests.post(url='',data=json.dumps({'key1':'value1','key2':'value2'}),headers={'Content-Type':'application/json'})

或者

  requests.post(url='',json={{'key1':'value1','key2':'value2'}},headers={'Content-Type':'application/json'})

(4)请求正文是binary

 requests.post(url='',files={'file':open('test.xls','rb')},headers={'Content-Type':'binary'})

转载请注明出处:https://www.cnblogs.com/shapeL/p/9037035.html

python3+requests:get/post请求的更多相关文章

  1. python3&plus;requests:post请求四种传送正文方式(详解)

    前言:post请求我在python接口自动化2-发送post请求详解(二)已经讲过一部分了,主要是发送一些较长的数据,还有就是数据比较安全等,可以参考Get,Post请求方式经典详解进行学习一下. 我 ...

  2. python3&plus;requests:post请求四种传送正文方式

    https://www.cnblogs.com/insane-Mr-Li/p/9145152.html 前言:post请求我在python接口自动化2-发送post请求详解(二)已经讲过一部分了,主要 ...

  3. python3&plus;requests get&sol;post 请求

    1.get请求 (1)没有请求参数类型 1 response = requests.get(url='') 2 print(response.text) (2)有请求参数的类型(键值对形式表示参数) ...

  4. Python常见问题 - python3 使用requests发送HTTPS请求报certificate verify failed 错误

    当你使用 requests 发送HTTPS请求时 requests.get(url, parmas=parmas, headers=header, cookies=cookie) 出现了以下错误 HT ...

  5. Python3 网络爬虫(请求库的安装)

    Python3 网络爬虫(请求库的安装) 爬虫可以简单分为几步:抓取页面,分析页面和存储数据 在页面爬取的过程中我们需要模拟浏览器向服务器发送请求,所以需要用到一些python库来实现HTTP的请求操 ...

  6. python3&plus;requests库框架设计01-自动化测试框架需要什么?

    什么是自动化测试框架 关于自动化测试框架的定义有很多,在我大致理解下就是把能实现不同功能的软件组合在一起,实现特定的目的,这就是一个简单的自动化测试框架. 接口自动化测试框架核心无非是选择 一个用来编 ...

  7. python3&plus;requests:接口自动化测试(二)

    转载请注明出处:https://www.cnblogs.com/shapeL/p/9188495.html 前言:上篇文章python3+requests+unittest:接口自动化测试(一):ht ...

  8. 【python3&plus;request】python3&plus;requests接口自动化测试框架实例详解教程

    转自:https://my.oschina.net/u/3041656/blog/820023 [python3+request]python3+requests接口自动化测试框架实例详解教程 前段时 ...

  9. Python3&plus;Requests&plus;Excel完整接口自动化框架

    框架整体使用Python3+Requests+Excel:包含对实时token的获取 框架结构图 1.------base -------runmethond.py runmethond:对不同的请求 ...

  10. Python3 &plus; requests &plus; unittest接口测试

    一.缘 起 笔者最近完成了基于Python3 + requests + unittest的接口测试脚本,故在此做一下记录,于己为复盘,于彼为学习和参考 二.思 路 接口测试无非三步: 首先,造数据 - ...

随机推荐

  1. hierarchyid

    hierarchyid: http://www.cnblogs.com/shanyou/archive/2011/07/01/2095968.html RABBITMQ: http://www.rab ...

  2. 【leetcode】Scramble String

    Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two no ...

  3. RSS

    RSS的基本概念 什么是RSS,RSS是在线共享内容的一种简易方式(也叫聚合内容,Really Simple Syndication).网站提供RSS输出有利于让用户获取网站内容的最新更新.用户可以使 ...

  4. Android中的IMEI

    国际移动设备识别码(IMEI:International Mobile Equipment Identification Number)是区别移动设备的标志,储存在移动设备中,可用于监控被窃或无效的移 ...

  5. nyoj 54-小明的存钱计划

    点击打开链接 小明的存钱计划 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 小明的零花钱一直都是自己管理.每个月的月初妈妈给小明300元钱,小明会预算这个月的花销,并且 ...

  6. SQL Server 常用函数使用方法&lpar;持续更新&rpar;

    之前就想要把一些 SQL 的常用函数记录下来,不过一直没有实行...嘿嘿... 直到今天用到substring()这个函数,C# 里面这个方法起始值是 0,而 SQL 里面起始值是 1.傻傻分不清楚. ...

  7. windows10安装ubuntu16&period;04双系统

    因为科研需要,主要在ubuntu系统中进行学习开发,介绍一下安装windows10下安装ubuntu的经验. 1.工具 u盘(或者你也可以在你的硬盘中分出一部分FAT32的硬盘空间) Easyuefi ...

  8. &lbrack;BOI2004&rsqb;Sequence

    题面描述 给定整数数组$a_1,a_2,a_3...a_n$,求递增数组$b_1,b_2,b_3...b_n$ 使得$|a_1 - b_1| + |a_2 - b_2| + ... + |a_n - ...

  9. LeetCode Valid Parenthesis String

    原题链接在这里:https://leetcode.com/problems/valid-parenthesis-string/description/ 题目: Given a string conta ...

  10. Html5 突破微信限制实现大文件分割上传

    先来前端代码 <!DOCTYPE html> <html> <head> <meta name="viewport" content=&q ...