Python基础入门学习笔记 054 论一只爬虫的自我修养2:实战


1 import urllib.request 2 3 response = urllib.request.urlopen('placekitten/g/500/600')# 返回文件对象response 4 cat_imag = response.read() 5 6 with open('cat_500_600.jpg','wb') as f: 7 f.write(cat_imag)

1 >>> response.geturl() 2 'placekitten/g/500/600' 3 >>> response.info() 4 <httplient.HTTPMessage object at 0x00000000034EAA20> 5 >>> print(response.info()) 6 Date: Sat, 27 Jul 2019 02:44:18 GMT 7 ContentType: image/jpeg 8 TransferEncoding: chunked 9 Connection: close 10 SetCookie: __cfduid=d3cd08233581619b9ef8464ae93f7d5ff1564195458; expires=Sun, 26Jul20 02:44:18 GMT; path=/; dain=.placekitten; HttpOnly 11 AccessControlAllowOrigin: * 12 CacheControl: public, maxage=86 13 Expires: Sun, 28 Jul 2019 02:44:18 GMT 14 CFCacheStatus: HIT 15 Age: 66459 16 Vary: AcceptEncoding 17 Server: cloudflare 18 CFRAY: 4fcb454ecc35ce6bLHR 19 20 21 >>> response.getcode() 22 200



上一篇:Python基础入门学习笔记 053 论一只爬虫的自我修养

下一篇:Python基础入门学习笔记 073 GUI的终极选择:Tkinter10


Python
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图