好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > PowerShell中使用curl(Invoke-WebRequest)的方法教程

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

熱門標簽:什么渠道可以找外呼系統客戶 湖州電銷防封卡 安徽400電話辦理 雷霆電話機器人電話 信陽話務外呼系統怎么收費 金融電銷公司怎么辦理外呼系統 真人和電話機器人對話 電話智能外呼系統誠信合作 使用電話機器人電銷是否違法

前言

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 -AutoSize

CommandType Name      Version Source
----------- ----      ------- ------
Alias  curl -> Invoke-WebRequest
Alias  iwr -> Invoke-WebRequest
Alias  wget -> Invoke-WebRequest

Invoke-WebRequest簡單用法

1.用途

Gets content from a web page on the Internet.

獲取http web請求訪問內容

2.語法Syntax

Parameter Set: Default
Invoke-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.com

StatusCode  : 200
StatusDescription : OK
Content   : !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

會發現content內容被截斷了。想要獲取完整的content:

ps> curl https://www.google.com | Select -ExpandProperty Content

3.2添加header

-Headers @{"accept"="application/json"}

3.3指定Method

-Method Get

3.4將獲取到的content輸出到文件

-OutFile 'c:\Users\rmiao\temp\content.txt'

3.5表單提交

For example:
$R = Invoke-WebRequest http://website.com/login.aspx 
$R.Forms[0].Name = "MyName" 
$R.Forms[0].Password = "MyPassword" 
Invoke-RestMethod http://website.com/service.aspx -Body $R

or

Invoke-RestMethod http://website.com/service.aspx -Body $R.Forms[0]

3.6內容篩選

PS C:\Users\rmiao> $R = Invoke-WebRequest -URI http://www.bing.com?q=how+many+feet+in+a+mile
PS C:\Users\rmiao> $R.AllElements | where {$_.innerhtml -like "*=*"} | Sort { $_.InnerHtml.Length } | Select InnerText -
First 5

innerText
---------
=

1
Next
=

3.7一個登陸示例

#發送一個登陸請求,聲明一個sessionVariable 參數為fb, 將結果保存在$R
#這個變量FB就是header.cookie等集合
PS C:\Users\rmiao> $R=curl http://www.facebook.com/login.php -SessionVariable fb
PS C:\Users\rmiao> $FB


Headers    : {}
Cookies    : System.Net.CookieContainer
UseDefaultCredentials : False
Credentials   :
Certificates   :
UserAgent    : Mozilla/5.0 (Windows NT; Windows NT 6.3; en-US) WindowsPowerShell/4.0
Proxy     :
MaximumRedirection : -1


#將response響應結果中的第一個form屬性賦值給變量Form
PS C:\Users\rmiao> $Form=$R.Forms[0]
PS C:\Users\rmiao> $Form.fields

Key               Value
---               -----
lsd               AVqQqrLW
display
enable_profile_selector
isprivate
legacy_return            0
profile_selector_ids
return_session
skip_api_login
signed_next
trynum              1
u_0_0
u_0_1
lgnrnd              214945_qGeg
lgnjs              n
email
pass
persistent
default_persistent           1



# 查看form
PS C:\Users\rmiao> $Form | Format-List


Id  : login_form
Method : post
Action : /login.php?login_attempt=1lwv=100
Fields : {[lsd, AVqQqrLW], [display, ], [enable_profile_selector, ], [isprivate, ]...}


#查看屬性
$Form.fields

#設置賬號密碼
$Form.Fields["email"] = "User01@Fabrikam.com"
$Form.Fields["pass"] = "P@ssw0rd"

#發送請求并保存結果為$R
$R=Invoke-WebRequest -Uri ("https://www.facebook.com" + $Form.Action) -WebSession $FB -Method POST -Body $Form.Fields

#查看結果
PS C:\Users\rmiao> $R.StatusDescription
OK

雖然沒有curl那么主流,但一樣可以成為http訪問的一個選擇。

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

參考

https://technet.microsoft.com/en-us/library/hh849901.aspx

標簽:山南 濟南 運城 湛江 六盤水 鶴崗 德州 岳陽

巨人網絡通訊聲明:本文標題《PowerShell中使用curl(Invoke-WebRequest)的方法教程》,本文關鍵詞  PowerShell,中,使用,curl,Invoke-WebRequest,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《PowerShell中使用curl(Invoke-WebRequest)的方法教程》相關的同類信息!
  • 本頁收集關于PowerShell中使用curl(Invoke-WebRequest)的方法教程的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 抠逼摸奶| 国产精品打着电话偷着情| 小sao货水真多ji巴cao| 大尺度囚禁文肉多一女多男| 禁网站在线观看免费视频| 京野结衣一区二区在线播放| 欧美一级做a爰片久久毛片| 痴母动漫在线观看| 性欧美free荷兰hd| 长篇乱肉合集乱500小说日本| 国产伦精品一区二区三区免费舒淇 | 鸥美性| 久久伦理电影| 免费无遮挡??视频网站酒店| 91麻豆天美国产欧美日韩aV| 农村女人偷人一级大毛片| GOGO全球高清大尺度无吗亚| 美女穿jk被灌水憋尿视频| 男人和女人做爽爽视频可在线观看 | 国产精品黄页网站在线播放免费| 中文字幕第八页| 国产AV精品无码一区二区| asian极品裸体女pics| 最新电影在线免费看| 欧美人与zooz| 国产高潮????| 男人扒开女人的内裤亲吻桶进去| 一女被各种np小黄文| 夺宝幸运星3| 国产精品99久久久久久人| 好长好硬好难受好想啪啪| 被动的少妇在线观看| 久久精品天天爽夜夜爽| 圣洁仙子被调教鞭打臀缝小说| 国产91短视频| 国产69精品久久久久久精| 摧残蹂躏挣扎哀嚎惨叫| 女配养崽军婚| 在线一区观看| 无码人妻精产国品一二三| 国产一区二区极品韩国女主播|