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 ...
随机推荐
- poj 1363
这是一道数据结构的问题,用到了栈的知识.题目大意讲的是每一次有N辆车从A到B,但是要将车辆的顺序重新排列,可以通过中转站C来辅助排列,但是C符合先进后出的原则,这一点和栈的特性相同. 整个重新排序的过 ...
- Java常用正则表达式验证工具类RegexUtils.java
import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexUtils{ /** * 正则表达式 ...
- sublimetext 使用正则表达式匹配中文
[\x{4e00}-\x{9fa5}] ============================================= 参考资料 1.在javascript下正确的\x4e00-\x9fa ...
- systemtap
http://www.ibm.com/developerworks/library/l-systemtap/index.html http://wiki.eclipse.org/Linux_Tools ...
- Sea.js学习4——Sea.js的配置
可以对 Sea.js 进行配置,让模块编写.开发调试更方便. seajs.config seajs.config(options) 用来进行配置的方法. seajs.config({ // 别名配置 ...
- SQL阻塞原因造成系统多功能无响应的分析解决思路
最近遇到一个sqlserver项目,月底会出现多个财务相关功能出现不定期操作无响应问题 通过查询SQL阻塞信息,定位到阻塞源头spid.该会话的状态.等待事件及执行的SQL脚本 根据spid查询该会话 ...
- 调试技巧--Windows端口号是否被占用
调试技巧--Windows端口号是否被占用 一.端口概念 10.0.0.0~10.255.255.255,172.16.0.0~172.16.255.255, 192.168.0.0~192.168. ...
- 基于adt-bundle-windows-x86的android开发环境搭建
0,简介: 最近简单着手了解 android 开发.工欲善其事,必先利其器. 我本人不太喜欢使用java 开发,所以简单了解了下其 c# c++都可以进行android 开发,用c++的话要使用NDK ...
- silverlight简单数据绑定2
<Grid x:Name="LayoutRoot" Background="white" Loaded="LayoutRoot_Loaded&q ...
- 使用asmcmdcp命令把datafile从文件系统移动(move)到asm磁盘组中 针对11gR2
使用asmcmd cp命令 把datafile从文件系统移动(move)到asm磁盘组中--针对11gR2 参考原文:How to Move a Datafile from Filesystem to ...