Powershell 检索需要登录的网页内容-调用WebRequest-未返回表单-密码输入字段无值
我试图保存需要会话登录的网页内容;我曾尝试将wget与useragent、用户名(e/login)和密码(p/password)输入一起使用,并试图保存cookies文件,但意识到没有写入任何内容。然后我继续使用此方法(在PowerShell 6中): 但是当我尝试的时候Powershell 检索需要登录的网页内容-调用WebRequest-未返回表单-密码输入字段无值,powershell,authentication,invoke-webrequest,Powershell,Authentication,Invoke Webrequest,我试图保存需要会话登录的网页内容;我曾尝试将wget与useragent、用户名(e/login)和密码(p/password)输入一起使用,并试图保存cookies文件,但意识到没有写入任何内容。然后我继续使用此方法(在PowerShell 6中): 但是当我尝试的时候 $Form = $R.Forms[0] 没有表格 Cannot index into a null array. At line:1 char:1 + $Form = $R.Forms[0] + ~~~~~~~~~~~~~~
$Form = $R.Forms[0]
没有表格
Cannot index into a null array.
At line:1 char:1
+ $Form = $R.Forms[0]
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
输入字段如下所示:
$R.InputFields
outerHTML : <input type="hidden" name="u" value="https://app.asana.com/?rr=296832" />
tagName : INPUT
type : hidden
name : u
value : https://app.asana.com/?rr=296832
outerHTML : <input type="hidden" name="i" value="password" />
tagName : INPUT
type : hidden
name : i
value : password
outerHTML : <input type="hidden" name="src" value="login" />
tagName : INPUT
type : hidden
name : src
value : login
outerHTML : <input type="hidden" name="auth" />
tagName : INPUT
type : hidden
name : auth
outerHTML : <input type="hidden" name="xsrf_token" value="60a3a8255cfe364b3fbec08ec6c2106e:1578648571483" />
tagName : INPUT
type : hidden
name : xsrf_token
value : 60a3a8255cfe364b3fbec08ec6c2106e:1578648571483
outerHTML : <input tabindex="1" type="email" name="e" id="email_input" value="" />
tagName : INPUT
tabindex : 1
type : email
name : e
id : email_input
value :
outerHTML : <input tabindex="2" type="password" name="p" id="password_input" />
tagName : INPUT
tabindex : 2
type : password
name : p
id : password_input
但是InputFields[6]没有值属性,即密码
Exception setting "Value": "The property 'Value' cannot be found on this object. Verify that the property exists and can be set."
我想不出另一种输入密码的方法。
或者可能有一种完全不同的方法
登录后,我将访问我想要的网页(在会话中),并使用-OutFile保存内容。最后,我将使用Selenium并保存页面源代码。我仍然很想知道这里的解决方案是什么。最后我使用了Selenium并保存了页面源代码。我仍然很想知道这里的解决方案是什么。
$R.InputFields[5].Value="nats@email"
Exception setting "Value": "The property 'Value' cannot be found on this object. Verify that the property exists and can be set."