前言
网络爬虫的起步就是根据URL来获取网页的HTML信息。
在python3中,可以使用urllib.request和requests进行网页爬取。
urllib是python内置的,只要安装了python就可以使用这个库。
安装Requests
打开cmd,输入:
pip install requests
如果提示:
Could not find a version that satisfies the requirement requests (from version : )
重新执行一遍命令
获得源码
github地址:
https://github.com/requests/requests
你可以克隆公共版本库:
git clone git://github.com/kennethreitz/requests.git
获得代码之后,你就可以将其嵌入到你的python包中,或者安装到你的site-package:
cd requests
pip install