urllib.request
【urllib.request】
1、urlopen结果保存在内存。
2、ulrretrieve结果保存到文件。
3、response有read方法。
4、可以创建Request对象。
5、发送Post数据,需要encode()成ascii的byte.
6、url中加入query
7、加入User-Agent参数。
8、错误。
urlopen raises URLError
when it cannot handle a response (though as usual with Python APIs, built-in exceptions such as ValueError
, TypeError
etc. may also be raised).
HTTPError
is the subclass of URLError
raised in the specific case of HTTP URLs.
The exception classes are exported from the urllib.error
module.
9、http.server.BaseHTTPRequestHandler.responses
is a useful dictionary of response codes in that shows all the response codes used by RFC 2616. The dictionary is reproduced here for convenience
包含所有的HTTP错误码。
urllib.request的更多相关文章
- 爬虫初探(1)之urllib.request
-----------我是小白------------ urllib.request是python3自带的库(python3.x版本特有),我们用它来请求网页,并获取网页源码. # 导入使用库 imp ...
- 关于python3.X 报"import urllib.request ImportError: No module named request"错误,解决办法
#encoding:UTF-8 import urllib.request url = "http://www.baidu.com" data = urllib.request.u ...
- python3爬虫初探(一)之urllib.request
---恢复内容开始--- #小白一个,在此写下自己的python爬虫初步的知识.如有错误,希望谅解并指出. #欢迎和大家交流python爬虫相关的问题 #2016/6/18 #----第一把武器--- ...
- urllib.request ProxyHandler
import urllib.request proxy_support = urllib.request.ProxyHandler({}) opener = urllib.request.build_ ...
- python3.6 urllib.request库实现简单的网络爬虫、下载图片
#更新日志:#0418 爬取页面商品URL#0421 更新 添加爬取下载页面图片功能#0423 更新 添加发送邮件功能# 优化 爬虫异常处理.错误页面及空页面处理# 优化 爬虫关键字黑名单.白名单,提 ...
- 爬虫小探-Python3 urllib.request获取页面数据
使用Python3 urllib.request中的Requests()和urlopen()方法获取页面源码,并用re正则进行正则匹配查找需要的数据. #forex.py#coding:utf-8 ' ...
- urllib.request.Request
import urllib.request #可以将url先构造成一个Request对象,传进urlopen #Request存在的意义是便于在请求的时候传入一些信息,而urlopen则不 reque ...
- 【转】python3 urllib.request 网络请求操作
python3 urllib.request 网络请求操作 基本的网络请求示例 ''' Created on 2014年4月22日 @author: dev.keke@gmail.com ''' im ...
- Python3 urllib.request库的基本使用
Python3 urllib.request库的基本使用 所谓网页抓取,就是把URL地址中指定的网络资源从网络流中读取出来,保存到本地. 在Python中有很多库可以用来抓取网页,我们先学习urlli ...
随机推荐
- POI给Excel添加数字筛选
HSSFSheet sheet = workbook.createSheet("list"); CellRangeAddress ce = CellRangeAddress.val ...
- [Eclipse] - 集成JBoss7热加载和自动发布
使用Eclipse + JBoss开发时,总是要重启项目或JBoss,烦人.下面方法可以很简单的实现Eclipse + JBoss热加载和自动发布. 我的环境是JBoss 7.1.1 Final 1) ...
- python 实现二分法查找
二分查找图 二叉树: 代码 #!/usr/bin/python #-*-coding:utf-8-*- #----------------------------------------------- ...
- [工具开发] keepalived使用nagios监控脚本
最近在做开发和办公环境的高可用,采用的是keepalived:keepalived基于Linux内核支持的LVS,既能实现高可用,又能实现负载均衡,非常实用. keepalived监控服务状态时可以用 ...
- 53. Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- SQL Server 2012 创建操作员
数据库可以通知操作员,给操作员发送邮件,就要在SQL Server 的代理中启用数据库邮件,前提是先配置出数据库邮件 右键SQL Server代理,选择属性,按下图设置 保存后,右键操作员,选择新建操 ...
- Hadoop学习10--常用命令记录帖
1.列出所有正在执行的任务 hadoop job -list 2.kill任务 hadoop job -kill 任务名
- ubuntu16.04解决播放swf视频文件问题
使用下面 sudo apt-get install swfdec-gnome
- 便捷的php操作mysql库MysqliDb
github 地址:https://github.com/joshcam/PHP-MySQLi-Database-Class MysqliDb -- Simple MySQLi wrapper and ...
- view抖动效果
1.使用属性动画 ViewPropertyAnimator.animate(webView).translationX(20).setInterpolator(new CycleInterpolato ...