python3----requests







import requests def get_html_text(url):
try:
r = requests.get(url, timeout=30)
r.raise_for_status() # 如果状态不是200,引发HTTPError 异常
r.encoding = r.apparent_encoding
return r.text
except:
return "产生异常" if __name__ == "__main__":
url = "http://www.baidu.com"
print(get_html_text(url))





http://blog.csdn.net/linzch3/article/details/60750355
python3----requests的更多相关文章
- python3+requests库框架设计01-自动化测试框架需要什么?
什么是自动化测试框架 关于自动化测试框架的定义有很多,在我大致理解下就是把能实现不同功能的软件组合在一起,实现特定的目的,这就是一个简单的自动化测试框架. 接口自动化测试框架核心无非是选择 一个用来编 ...
- python3+requests:接口自动化测试(二)
转载请注明出处:https://www.cnblogs.com/shapeL/p/9188495.html 前言:上篇文章python3+requests+unittest:接口自动化测试(一):ht ...
- 【python3+request】python3+requests接口自动化测试框架实例详解教程
转自:https://my.oschina.net/u/3041656/blog/820023 [python3+request]python3+requests接口自动化测试框架实例详解教程 前段时 ...
- Python3+Requests+Excel完整接口自动化框架
框架整体使用Python3+Requests+Excel:包含对实时token的获取 框架结构图 1.------base -------runmethond.py runmethond:对不同的请求 ...
- Python3 + requests + unittest接口测试
一.缘 起 笔者最近完成了基于Python3 + requests + unittest的接口测试脚本,故在此做一下记录,于己为复盘,于彼为学习和参考 二.思 路 接口测试无非三步: 首先,造数据 - ...
- Python3 requests与http.cookiejar的使用(cookie的保存与加载)
在学习Python之余,发现Python2与Python3 有很大的变化,之前使用urllib和cookielib来保存cookie,发现很繁琐,于是改用requests.发现cookielib在3. ...
- python3+requests+unittest:接口自动化测试(一)
转载请表明出处:https://www.cnblogs.com/shapeL/p/9179484.html 简单介绍框架的实现逻辑,参考代码的git地址: https://github.com/zha ...
- 基于Python3+Requests的贴吧签到助手
因为总是忘记签到,所以尝试写了一个签到脚本,因为使用的是Python3,所以没法使用Urllib2,于是选择了Requests,事实证明,Requests比Urllib2好用.整体思路比较简单,就是模 ...
- Python常见问题 - python3 requests库提示警告InsecureRequestWarning的问题
当使用 requests 库发送请求时报了以下警告 D:\python3.6\lib\site-packages\urllib3\connectionpool.py:847: InsecureRequ ...
- python3 requests 获取 拉勾工作数据
#-*- coding:utf-8 -*- __author__ = "carry" import requests,json for x in range(1, 15): url ...
随机推荐
- HDU 5389 Zero Escape(dp啊 多校)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5389 Problem Description Zero Escape, is a visual no ...
- SuperMap iServer 9D HBase使用
需提前将HBase进行部署,参考上篇部署文档 https://www.cnblogs.com/zhangyongli2011/p/9982143.html (转发请注明出处:http://www.cn ...
- SCF: 简单配置门面
SCF: 简单配置门面 [English] [中文] Simple Configuration Facade, 简写为 SCF.是 代码 和 外部配置 (properties文件, 环境变量,系统/ ...
- 总结js(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
http://hi.baidu.com/yashua839/blog/item/131fdb2fe547ef221f3089af.html一.Iframe 篇 //&&&&am ...
- js闭包的应用
<ul id="ul1"> <li style="border:1px solid red;">1</li> <li ...
- USES_CONVERSION的使用和注意
USES_CONVERSION是用来转换类型的,比如我们很常见的问题: 在Socket编程时候,我们的IP地址从界面上输进去一般都使用CString类型的,可是在SOCKADDR_IN中的inet_a ...
- mybatis 映射器
1 映射器 Mapper 是由java接口和 XML 文件共同组成.它的作用如下 1)定义参数类型 2)描述缓存 3)描述 SQL 语句 4)定义查询结果和POJO的映射关系 2 SqlSession ...
- StrongLoop
http://loopback.io/getting-started/ 使用 StrongLoop 创建 Node.js MySQL 应用程序 StrongLoop 是 IBM 的一家子公司,Stro ...
- 如何使用SignalTap II觀察reg與wire值? (SOC) (Verilog) (Quartus II) (SignalTap II)
Abstract撰寫Verilog時,雖然每個module都會先用ModelSim或Quartus II自帶的simulator仿真過,但真的將每個module合併時,一些不可預期的『run-time ...
- HADOOP 2.6 INSTALLING ON UBUNTU 14.04 (hadoop 2.6 部署到ubuntu 14.04上面)
Hadoop on Ubuntu 14.04 In this chapter, we'll install a single-node Hadoop cluster backed by the Had ...