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

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

#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()
其中

rematch = r'http://down.360.cn/360sd/360sd_se_(.*?)exe'
这行代码中可能由于360杀毒下载页面中的文件名字有不同,可以进行相应的更改

转载于:https://my.oschina.net/yangyanxing/blog/159219

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值