|
本帖最后由 2011895866818 于 2017-7-28 13:40 编辑
引用:https://www.ithome.com/html/win10/318104.htm
原作者用hash命名,不好分辨图片的来源
改进文件名,加上发布日期与照片描述
bing-pic.zip
(1.22 KB, 下载次数: 34)
- #
- $x = Split-Path -Parent $MyInvocation.MyCommand.Definition
- cd $x
- if (!(Test-Path images)) {mkdir images} else { }
- cd images
- $url = "http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=10"
- $data = Invoke-RestMethod $url
- #下载8张
- #$range = 1..8
- #下载最近1张
- $range = 1..1
- $count = $range.Count
- for($i=0; $i -lt $count; $i++)
- {
- $temp = $data.images.Get($i)
- $urlsplit = -Join("http://www.bing.com",$temp.url)
-
- $startdate = $temp.startdate
- $copyright = $temp.copyright
- $picname = $urlsplit.Split("/")[-1]
- $name = -Join($startdate + "-" + $copyright + "-" +$picname)
- #去掉9种非法字符
- $name = $name -replace '(\\|/|:|\*|\?|<|>|\||")',"+"
- $name
-
- Invoke-WebRequest $urlsplit -OutFile $name
- }
- echo ok!
- pause
复制代码
|
评分
-
查看全部评分
|