码迷,mamicode.com
首页 > 系统相关 > 详细

powershell 2.0 下载 bootcdn 资源

时间:2018-08-27 12:34:35      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:load   sub   for   shell   inpu   pow   path   input   tps   

powershell 2.0 , win 7 以上操作系统可用。

[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")

$path = "D:\front\"
$library = "element-ui"

$json = "[]"
$json = $client.DownloadString("https://api.bootcdn.cn/libraries/"+ $library +".json")
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$obj = $ser.DeserializeObject($json)
##$info = ConvertFrom-Json -InputObject $json
if($obj.assets.length){
    $array = $obj.assets[0].files
    $version = $obj.assets[0].version
    $client = new-object System.Net.WebClient
    foreach ($src in $array){
    $url = "https://cdn.bootcss.com/"+ $library +"/" + $version +"/" + $src 
    $des = ( $path + $library + "@" + $version  +"/" + $src ).replace("/", "\")
    if((Test-Path $des.Substring(0,$des.LastIndexOf(‘\‘)) ) -eq $False)
    {
        New-Item $des.Substring(0,$des.LastIndexOf(‘\‘)) -type directory
    }
    $client.DownloadFile($url,$des)
    }
}

 

powershell 2.0 下载 bootcdn 资源

标签:load   sub   for   shell   inpu   pow   path   input   tps   

原文地址:https://www.cnblogs.com/edit/p/9541206.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!