标题: [问题求助] 怎样用powershell批量下载公众号的图片 [打印本页]
作者: 小白龙 时间: 昨天 16:10 标题: 怎样用powershell批量下载公众号的图片
我想下载下面的连续的图片到桌面上的ABC文件夹中, 没有找到规律, 求路过大佬支招
https://mp.weixin.qq.com/s/YtWEQ_kORUmh97sAEMwUjw
作者: flashercs 时间: 22 分钟前
- # 下载微信图片
- $ProgressPreference = 'SilentlyContinue'
- Add-Type -AssemblyName System.Web
- [System.Net.ServicePointManager]::SecurityProtocol = 'Tls, Tls11, Tls12'
- $dstdir = [io.path]::Combine([environment]::GetFolderPath([environment+specialfolder]::Desktop), 'ABC') # 下载保存目录
- $di = [io.directory]::CreateDirectory($dstdir)
- $result = Invoke-WebRequest -Uri 'https://mp.weixin.qq.com/s/YtWEQ_kORUmh97sAEMwUjw' -SessionVariable session1 # 下载地址url - $result.Content 乱码:utf8解析成ANSI
- foreach ($img in $result.Images) {
- $src = if ($img.'data-src') { $img.'data-src' }else { $img.src }
- if (-not $src) { continue }
- $uri = [uri]$src
- $nvc = [System.Web.HttpUtility]::ParseQueryString($uri.Query)
- $wx_fmt = $nvc['wx_fmt']
- $picname = ($uri.Segments[-2] -replace '/') + ".${wx_fmt}"
- $picpath = [io.path]::Combine($di.FullName, $picname)
- "downloading: $src"
- Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile $picpath -WebSession $session1
- }
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |