1 Star 0 Fork 0

chobit/My_JDlingyu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
html_downloader.py 838 Bytes
一键复制 编辑 原始数据 按行查看 历史
chobit 提交于 2017-02-27 22:57 +08:00 . 增加多线程功能,属于测试版本
#!/usr/bin/Python
# -*- coding: utf-8 -*-
import os
import urllib
import urllib2
class HtmlDownloader(object):
def downloaderHtml(self, url):
if url is None:
return
# request = urllib2.Request(url, headers=self.headers)
response = urllib2.urlopen(url)
if response.getcode() != 200:
return None
return response.read()
def downImg(self,urllist,title):
if urllist is None:
return
name = 1
print 'downing .....'
path = 'file/' + title
if not os.path.exists(path):
os.mkdir(path)
for imgurl in urllist:
urllib.urlretrieve(imgurl,path+'\%s.jpg' %(name))
name += 1
else:
print '文件已下载'
print 'Get ', len(urllist), ' images!'
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chobit/My_JDlingyu.git
git@gitee.com:chobit/My_JDlingyu.git
chobit
My_JDlingyu
My_JDlingyu
master

搜索帮助