国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PowerShell > 正文

PowerShell中使用curl(Invoke-WebRequest)的方法教程

2020-05-30 20:21:24
字體:
來源:轉載
供稿:網友

前言

PowerShell能干什么呢?PowerShell首先是個Shell,定義好了一堆命令與操作系統,特別是與文件系統交互,能夠啟動應用程序,甚至操縱應用程序;第二,PowerShell允許將幾個命令組合起來放到文件里執行,實現文件級的重用,也就是說有腳本的性質;第三,PowerShell能夠能夠充分利用.Net類型和COM對象,來簡單地與各種系統交互,完成各種復雜的、自動化的操作。

當我們習慣了windows的界面模式就很難轉去命令行,甚至以命令行發家的git也涌現出各種界面tool。然而命令行真的會比界面快的多,如果你是一個碼農。

situation:接到需求分析bug,需要訪問http。那臺機器屬于product,不允許裝postman。我只能手動命令行來發請求。發現了內置的PowerShell中有curl命令。歡喜試了半天,總是命令不對,google發現這個curl是冒名頂替的,只是一個Invoke-WebRequest的alias。參考。

PS> Get-Alias -Definition Invoke-WebRequest | Format-Table -AutoSizeCommandType Name      Version Source----------- ----      ------- ------Alias  curl -> Invoke-WebRequestAlias  iwr -> Invoke-WebRequestAlias  wget -> Invoke-WebRequest

Invoke-WebRequest簡單用法

1.用途

Gets content from a web page on the Internet.

獲取http web請求訪問內容

2.語法Syntax

Parameter Set: DefaultInvoke-WebRequest [-Uri] <Uri> [-Body <Object> ] [-Certificate <X509Certificate> ] [-CertificateThumbprint <String> ] [-ContentType <String> ] [-Credential <PSCredential> ] [-DisableKeepAlive] [-Headers <IDictionary> ] [-InFile <String> ] [-MaximumRedirection <Int32> ] [-Method <WebRequestMethod> {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge | Patch} ] [-OutFile <String> ] [-PassThru] [-Proxy <Uri> ] [-ProxyCredential <PSCredential> ] [-ProxyUseDefaultCredentials] [-SessionVariable <String> ] [-TimeoutSec <Int32> ] [-TransferEncoding <String> {chunked | compress | deflate | gzip | identity} ] [-UseBasicParsing] [-UseDefaultCredentials] [-UserAgent <String> ] [-WebSession <WebRequestSession> ] [ <CommonParameters>]

3.簡單的幾個用法

3.1 Get請求

PS C:/Users/rmiao> curl -URi https://www.google.comStatusCode  : 200StatusDescription : OKContent   : <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many speci..."RawContent  : HTTP/1.1 200 OK     X-XSS-Protection: 1; mode=block     X-Frame-Options: SAMEORIGIN     Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"     Vary: Accept-Encoding     Transfer-Encoding: chunked            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 林口县| 潢川县| 赣州市| 广昌县| 双峰县| 石景山区| 承德县| 江陵县| 元朗区| 滨州市| 治县。| 贵阳市| 蒲城县| 广元市| 泸西县| 张家港市| 江都市| 康马县| 绿春县| 凌源市| 碌曲县| 常熟市| 东光县| 嘉善县| 隆回县| 屏东市| 怀宁县| 青田县| 封开县| 都兰县| 湟源县| 县级市| 临夏县| 河东区| 九龙坡区| 郓城县| 东安县| 沙洋县| 子洲县| 密云县| 文山县|