Stackoverflow的答案:
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
还有如progress bar的实现等等。
2012的requests,对http直接封装:
各类回答棒极了
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
import urllib2
response = urllib2.urlopen('http://www.example.com/')
html = response.read()import urllib
urllib.urlretrieve ("http://www.example.com/songs/mp3.mp3", "mp3.mp3")还有如progress bar的实现等等。
2012的requests,对http直接封装:
>>> import requests
>>>
>>> url = "http://download.thinkbroadband.com/10MB.zip"
>>> r = requests.get(url)
>>> print len(r.content)
10485760各类回答棒极了
使用Python下载文件
本文介绍了如何使用Python的不同库(如urllib2、requests)来从HTTP服务器下载文件,并提供了具体的代码示例。此外还展示了如何使用requests库获取文件大小。
1323

被折叠的 条评论
为什么被折叠?



