Powershell:通过WebClient获取网络上的资源

 时间:2026-04-24 01:22:56

1、1.创建WebClient对象:

$web = New-Object System.Net.WebClient

2、2.设置文本的编码:

$web.Encoding = [System.Text.Encoding]::UTF8

3、3.下载网页代码

$str = $web.DownloadString("http://localhost")

$str

4、4.获取文件资源

$url = "http://path.to/file"

$file = "\\localpath\to\file"

$web.DownloadFile($url,$file)

5、WebClient能够实现一个HTTP客户端,进而拓展的应用场景非常丰富,如 web自动化,网络爬虫,异步下载器等

  • sqlserver如何获取指定日期当月的最后一天?
  • Access怎么把数据表导出SharePoint网站
  • excel中使用vba的close方法
  • 在VBA中,如何编写入库单开单之代码?
  • 如何通过堡垒机连接虚拟机
  • 热门搜索
    天籁之音的意思 gcp是什么意思 十三点什么意思 黄菊花的作用 葡萄干有什么营养 吆喝的意思 21朵玫瑰代表什么 形同陌路什么意思 反刍是什么意思 沦陷是什么意思