我一直在處理Powershell約一個月。我對編碼和Powershell很新穎。Powershell Invoke-WebRequest,「Form」「form」在哪裏?
我GOOGLE瞭如何使用調用-的WebRequest
https://technet.microsoft.com/en-us/library/hh849901.aspx
或
https://gist.github.com/haraldfianbakken/32d5ac624c842a766df3
我曾嘗試同樣的事情有兩個鏈接。
所以我做了一個腳本。
$r = Invoke-WebRequest "https://idp.appery.io/idp/" -SessionVariable ws;
$r|Get-Member
它呼應了
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
BaseResponse Property System.Net.WebResponse BaseResponse {get;set;}
Content Property byte[] Content {get;}
Headers Property System.Collections.Generic.Dictionary[string,string] Headers {get;}
RawContent Property string RawContent {get;}
RawContentLength Property long RawContentLength {get;}
RawContentStream Property System.IO.MemoryStream RawContentStream {get;}
StatusCode Property int StatusCode {get;}
StatusDescription Property string StatusDescription {get;}
根據這些網站,它應該有一個表格。
這樣我就可以去這樣
$
r=Invoke-WebRequest http://www.facebook.com/login.php -SessionVariable fb
# Use the session variable that you created in Example 1. Output displays values for Headers, Cookies, Credentials, etc.
$fb
# Gets the first form in the Forms property of the HTTP response object in the $r variable, and saves it in the $form variable.
$form = $r.Forms[0]
# Pipes the form properties that are stored in the $forms variable into the Format-List cmdlet, to display those properties in a list.
$form | Format-List
# Displays the keys and values in the hash table (dictionary) object in the Fields property of the form.
$form.fields
# The next two commands populate the values of the "email" and "pass" keys of the hash table in the Fields property of the form. Of course, you can replace the email and password with values that you want to use.
$form.Fields["email"] = "[email protected]"
$form.Fields["pass"] = "[email protected]"
我想去確切上面的代碼相同的路徑,但是這一點,我沒有看到https://idp.appery.io/idp/,當「表」我看到網站,有一些表格可以輸入我的憑證,但是當我做了$ r | gm時,「表格」沒有顯示出來。
是否有任何原因沒有顯示?
是否有另一種方式來把我的憑據,所以我可以做兩個網站完全相同的東西?
非常感謝。
非常感謝!我嘗試這樣做,現在$ ie = New-Object -ComObject'internetExplorer.Application' $ ie.Visible = $ true $ ie.Navigate(「https://idp.appery.io/idp/」)我希望這是你正在談論的 – Kazu