python 3.3 下載固定鏈接文件并保存的方法
python 3.3 下載固定鏈接文件并保存。
import urllib.request print ("downloading with urllib") url = 'http://www.wzsky.net/img2013/uploadimg/20130906/1216294.jpg' f = urllib.request.urlopen(url) data = f.read() with open("d:/color/1216294.jpg", "wb") as code: code.write(data)
urllib在3.3版本有了很大變化:
urllib.error: ContentTooShortError; HTTPError; URLError
urllib.parse: parse_qs; parse_qsl; quote; quote_from_bytes; quote_plus; unquote
unquote_plus; unquote_to_bytes; urldefrag; urlencode; urljoin; urlparse; urlsplit; urlunparse; urlunsplit
urllib.request: AbstractBasicAuthHandler; AbstractDigestAuthHandler; BaseHandler;
CatheFTPHandler; FTPHandler; FancyURLopener; FileHandler; HTTPBasicAuthHandler; HTTPCookieProcessor; HTTPDefaultErrorHandler; HTTPDigestAuthHandler; HTTPErrorProcessorl; HTTPHandler; HTTPPasswordMgr; HTTPPasswordMgrWithDefaultRealm; HTTPRedirectHandler; HTTPSHandler;OpenerDirector;ProxyBasicAuthHandler ProxyDigestAuthHandler; ProxyHandler; Request; URLopener; UnknowHandler; build_opener; getproxies; install_opener; pathname2url; url2pathname; urlcleanup; urlopen; urlretrieve;
urllib.response: addbase; addclosehook; addinfo; addinfourl;
urllib.robotparser: RobotFileParser
另外,這個方法對于有防盜鏈的鏈接只能下載到防盜鏈圖片。
以上這篇python 3.3 下載固定鏈接文件并保存的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
python-django中的APPEND_SLASH實現(xiàn)方法
這篇文章主要介紹了python-django中的APPEND_SLASH實現(xiàn)方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06基于Python+Pyqt5開發(fā)一個應(yīng)用程序
今天給大家?guī)淼氖顷P(guān)于Python的相關(guān)知識,文章圍繞著Python+Pyqt5開發(fā)一個應(yīng)用程序展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下2021-06-06