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. 爬虫初探(1)之urllib.request

    -----------我是小白------------ urllib.request是python3自带的库(python3.x版本特有),我们用它来请求网页,并获取网页源码. # 导入使用库 imp ...

  2. 关于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 ...

  3. python3爬虫初探(一)之urllib.request

    ---恢复内容开始--- #小白一个,在此写下自己的python爬虫初步的知识.如有错误,希望谅解并指出. #欢迎和大家交流python爬虫相关的问题 #2016/6/18 #----第一把武器--- ...

  4. urllib.request ProxyHandler

    import urllib.request proxy_support = urllib.request.ProxyHandler({}) opener = urllib.request.build_ ...

  5. python3.6 urllib.request库实现简单的网络爬虫、下载图片

    #更新日志:#0418 爬取页面商品URL#0421 更新 添加爬取下载页面图片功能#0423 更新 添加发送邮件功能# 优化 爬虫异常处理.错误页面及空页面处理# 优化 爬虫关键字黑名单.白名单,提 ...

  6. 爬虫小探-Python3 urllib.request获取页面数据

    使用Python3 urllib.request中的Requests()和urlopen()方法获取页面源码,并用re正则进行正则匹配查找需要的数据. #forex.py#coding:utf-8 ' ...

  7. urllib.request.Request

    import urllib.request #可以将url先构造成一个Request对象,传进urlopen #Request存在的意义是便于在请求的时候传入一些信息,而urlopen则不 reque ...

  8. 【转】python3 urllib.request 网络请求操作

    python3 urllib.request 网络请求操作 基本的网络请求示例 ''' Created on 2014年4月22日 @author: dev.keke@gmail.com ''' im ...

  9. Python3 urllib.request库的基本使用

    Python3 urllib.request库的基本使用 所谓网页抓取,就是把URL地址中指定的网络资源从网络流中读取出来,保存到本地. 在Python中有很多库可以用来抓取网页,我们先学习urlli ...

随机推荐

  1. python built-in delattr()

    delattr(object,name) 使用此函数必须保证name是可以被删除,即先调用setattr(object,name,value) name必须是字符串并且是object的属性. 函数的作 ...

  2. python 列表操作

    列表的基本操作示例展示: append 功能:列表追加元素 name = ['sd','dfdf','drer'] name.append('sdsd') 返回结果:name ['sd', 'dfdf ...

  3. 重放攻击(Replay Attacks)

    重放攻击(Replay Attacks)1.什么是重放攻击顾名思义,重复的会话请求就是重放攻击.可能是因为用户重复发起请求,也可能是因为请求被攻击者获取,然后重新发给服务器. 2.重放攻击的危害请求被 ...

  4. Updatepanel 注册javascript 方法

    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "test", "alert ...

  5. win7 共享问题,"您可能没有权限使用网络资源"

    原文:http://hi.baidu.com/celian521/item/81b16e7c59996e295d178946 1 打开受访者的guest权限2 开始--运行--gpedit.msc3 ...

  6. [Spring] - Spring + Hibernate

    Spring整合Hibernate,花了很长时间研究,其中碰到的比较多问题. 使用的是Spring3.0+Hibernate4.1.6,Spring整合最新版本的Hibernate4.5,会抛些奇奇怪 ...

  7. int和NSInteger区别

    NSInteger会自动根据操作系统的位数(32或者64位)返回最大的类型 查到c语言中,int和long的字节数是和操作系统指针所占位数相等. 但c语言中说,long的长度永远大于或等于int ob ...

  8. 继承extends

    class Person{ String name; int age; void eat(){ System.out.println("吃饭"); } void introduce ...

  9. 源码阅读笔记 - 1 MSVC2015中的std::sort

    大约寒假开始的时候我就已经把std::sort的源码阅读完毕并理解其中的做法了,到了寒假结尾,姑且把它写出来 这是我的第一篇源码阅读笔记,以后会发更多的,包括算法和库实现,源码会按照我自己的代码风格格 ...

  10. 用Visual Studio调试Windows和驱动程序

    由于本人能力有限,翻译不足之处敬请谅解,欢迎批评指正:sunylat@163.com Visual Studio版本:Visual Studio 2015企业版,中文环境. MSDN原文:https: ...