python3 request模块初使用
import requests
class Interface_Request: def __init__(self,url,mobilephone,pwd):
'''login参数初始化'''
self.url = url
self.dict = {'mobilephone':mobilephone,'pwd':pwd} def http_request(self,way):
'''login接口请求'''
if way=='get':
return requests.get(self.url,self.dict).headers
elif way=='post':
while(True):
Question = input('是否使用json传递?请输入y/n')
if Question=='y' or Question=='n':
if Question=='y':
return requests.post(self.url,json=self.dict).headers
elif Question == 'n':
return requests.post(self.url,self.dict).headers
else:
print('请重新输入!')
continue
if __name__ == '__main__':
login = Interface_Request('URL地址','手机号','密码')
print('get传参:',login.http_request('get'))
print('post传参:',login.http_request('post'))
python3 request模块初使用的更多相关文章
- python3中urllib库的request模块详解
刚刚接触爬虫,基础的东西得时时回顾才行,这么全面的帖子无论如何也得厚着脸皮转过来啊! 原帖地址:https://www.2cto.com/kf/201801/714859.html 什么是 Urlli ...
- python接口自动化测试(一)-request模块
urllib.request模块是python3针对处理url的. 1. 首先导入: from urllib import request 2. 构造url,构造url的headers信息和传参[re ...
- 【python3+request】python3+requests接口自动化测试框架实例详解教程
转自:https://my.oschina.net/u/3041656/blog/820023 [python3+request]python3+requests接口自动化测试框架实例详解教程 前段时 ...
- 爬虫之urllib包以及request模块和parse模块
urllib简介 简介 Python3中将python2.7的urllib和urllib2两个包合并成了一个urllib库 Python3中,urllib库包含有四个模块: urllib.reques ...
- python自动化测试学习笔记-6urllib模块&request模块
python3的urllib 模块提供了获取页面的功能. urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capat ...
- dojo/request模块整体架构解析
总体说明 做前端当然少不了ajax的使用,使用dojo的童鞋都知道dojo是基于模块化管理的前端框架,其中对ajax的处理位于dojo/request模块.一般情况下我们使用ajax请求只需要引入do ...
- node.js的request模块
request模块让http请求变的更加简单.最简单的一个示例: 1: var request = require('request'); 2: 3: request('http://www.goo ...
- [转]python3之模块psutil系统性能信息
转自:https://www.cnblogs.com/zhangxinqi/p/9106265.html 阅读目录 1.psutil模块安装 2.获取CPU信息 3.内存信息 4.磁盘信息 5.网络信 ...
- 【转】Python3 configparse模块(配置)
[转]Python3 configparse模块(配置) ConfigParser模块在python中是用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(s ...
随机推荐
- 转载:ORA-12516 “TNS监听程序找不到符合协议堆栈要求的可用处理程序” 解决方案
ORA-12516 “TNS监听程序找不到符合协议堆栈要求的可用处理程序” 解决方案 简单描述一下场景,总共两台应用服务器,每台安装3个tomcat进行集群,并通过nginx做了负载均衡,今天在生 ...
- Go语言系列(七)- 读写操作
终端读写 1. 终端读写 操作终端相关文件句柄常量 os.Stdin:标准输入 os.Stdout:标准输出 os.Stderr:标准错误输出 2. 终端读写示例 package main impor ...
- [再寄小读者之数学篇](2014-10-27 Frobenius 范数是酉不变范数)
对任两酉阵 $U,V$, 有 $$\bex \sen{A}_F=\sen{UAV}_F. \eex$$ 事实上, $$\beex \bea \sen{UAV}_F^2&=\tr(V^*A^*U ...
- [再寄小读者之数学篇](2014-06-23 积分不等式 [中国科学技术大学2013年高等数学B 考研试题])
设 $f(x)$ 在 $[a,b]$ 上一阶连续可导, $f(a)=0$. 证明: $$\bex \int_a^b f^2(x)\rd x\leq \cfrac{(b-a)^2}{2}\int_a^b ...
- @JsonView的使用,entity中指定向前台返回哪些字段
使用步骤: 1.使用接口来声明多个视图 2.在值对象的get方法上指定视图 3.在Controller方法上指定视图
- Nginx故障排错及一个网站小实例
Nginx访问403错误: 1.没有首页文件 2.没有权限 例:chmod 700 /application/nginx/html/index.html 3.nginx.conf配置文件和首页文件不 ...
- densenet 中的shortcut connection
DenseNet 在FCN 网络中考虑加入skip connection,在resnet 中加入identity 映射,这些 shortcut connection等结构能够得到更好的检测效果,在d ...
- C++中数组作为形参进行传递(转)
有两种传递方法,一种是function(int a[]); 另一种是function(int *a) 这两种两种方法在函数中对数组参数的修改都会影响到实参本身的值! 对于第一种,根据之前所学,形参是实 ...
- 在vue中引入scss
先npm安装stylus和stylus-loader (我安装后,报错提示缺少stylus,所以第一步安装stylus,如果没有提示可省略第一步) 1.到 package.json ----- de ...
- 学习熟悉箭头函数, 类, 模板字面量, let和const声明
箭头函数:https://blog.csdn.net/qq_30100043/article/details/53396517 类:https://blog.csdn.net/pcaxb/articl ...