目录

通过一个python小脚本来下载最新的360杀毒安装程序

目录

小脚本很简单,主要是练习一下正则匹配,与简单的urllib库的应用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#coding: utf8
import urllib,re
import os

def getLastinstall():

    page = urllib.urlopen(r'http://sd.360.cn/download_center.html')
    html = page.read()
    page.close()
    rematch = r'http://down.360.cn/360sd/360sd_se_(.*?)exe'
    replusmatch = r'http://down.360.cn/360sd/360sd_plus_(.*?)exe'
    stdname = '360sd_'+(str(re.compile(rematch).findall(html)[0]))+'exe'
    downurlstd = r'http://down.360.cn/360sd/360sd_'+(str(re.compile(rematch).findall(html)[0]))+'exe'
    powname = '360sd_plus_'+(str(re.compile(replusmatch).findall(html)[0]))+'exe'
    downurlpow = r'http://down.360.cn/360sd/360sd_plus_'+(str(re.compile(replusmatch).findall(html)[0]))+'exe'
    localpath = os.getcwd()+r'/installpack'
    if not (os.path.isfile(stdname) and os.path.isfile(powname)):
        if not os.path.isdir('installpack'):
            os.makedirs('installpack')
        urllib.urlretrieve(downurlstd,localpath+'/'+stdname)
        urllib.urlretrieve(downurlpow,localpath+'/'+powname)
    else:
        print '目录中已经是线上最新版杀毒安装程序'

if __name__ =='__main__':
    getLastinstall()
  • 文章标题: 通过一个python小脚本来下载最新的360杀毒安装程序
  • 本文作者: 杨彦星
  • 本文链接: https://www.yangyanxing.com/article/817.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。