1. 结构相关
1.1 明确爬虫架构

1.2 URL管理器

URL管理器实现方式

互联网公司使用缓存数据库
个人可以使用内存,内存不够用或者想要永久储存,用关系型数据库
1.3网页下载器


关于Python3:
python 3.x中urllib库和urilib2库合并成了urllib库。。
其中urllib2.urlopen()变成了urllib.request.urlopen()
urllib2.Request()变成了urllib.request.Request()
1.3.1 网页下载器用法
方法1

方法2


方法3


对于Python 3.x,代码需要做相应改变:
import urllib.request
resp = urllib.request.urlopen('http://www.baidu.com')
print(resp.getcode())
网友评论