python批量下载文件

#!/usr/bin/python
# _*_ coding: utf-8 _*_

'''
Created on 2018年8月22日
'''

import urllib
import urllib2
import re

req = urllib2.Request('http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/')
# req = urllib2.Request('http://www.cvpapers.com/cvpr2014.html')
f = urllib2.urlopen(req)
localDir = 'E:\download\\'
urlList = []
for eachLine in f:
    line = eachLine.strip()
    if re.match('.*rpm.*', line):
#         print(line)
        wordList = line.split('\"')
        for word in wordList:
            if re.match('.*\.rpm$', word):
#                 print(word)
                urlList.append(word)

for everyFile in urlList:
#     print (everyFile)
    everyURL = "http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/"+everyFile
#     print(everyURL)
    localFile = localDir + everyFile
    try:            
      urllib.urlretrieve(everyURL, localFile) #按照url进行下载,并以其文件名存储到本地目录 
    except Exception,e: 
      continue

新闻标题:python批量下载文件
链接地址:http://www.hxwzsj.com/article/pogshi.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 手机网站制作 宜宾网站设计 成都响应式网站建设 古蔺网站建设 成都h5网站建设 成都网站制作 成都网站建设 重庆电商网站建设 成都网站建设 成都营销网站制作 成都网站设计 重庆外贸网站建设 外贸网站设计方案 攀枝花网站设计 高端网站设计 重庆企业网站建设 成都网站设计 成都网站制作 定制级高端网站建设 成都网站建设 营销型网站建设 温江网站设计