requests,Python HTTP 请求库,相当于 Android 的 Retrofit,它的功能包括 Keep-Alive 和连接池、Cookie 持久化、内容自动解压、HTTP 代理、SSL 认证、连接超时、Session 等很多特性,同时兼容 Python2 和 Python3。
第三方库的安装:
pip install urllib
pip install requests
小爬虫代码如下:
#获取center标签下的img标签
for img in imgs:
urllib.request.urlretrieve(img['src'], local + '%s.jpg' % (x))
x =x+1