powershell下载网站图片

$picurl = "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=10"

$data = invoke-webrequest $picurl

$decode = convertfrom-json -inputobject $data.content

$images = $decode.images

foreach ($image in $images)

{

$imageurl = $image.url

$fullurl = "http://www.bing.com" + $imageurl

$name = $image.hsh

invoke-webrequest $fullurl -outfile ($name + ".jgp")

}

foreach ($image in $images)

{

$imageurl = $image.url

#获取图片URL

$fullurl = "http://www.bing.com" + $imageurl

#补全URL

$name = $image.hsh

#获取图片名称

invoke-webrequest $fullurl -outfile ($name + ".jgp")

#下载到PS运行目录

}

转载于:https://www.cnblogs.com/chongyao/p/8249972.html

你可能感兴趣的:(powershell下载网站图片)