首页 > 解决方案 > 没有为反应页面设置powershell invoke-webrequest websession?

问题描述

我尝试在访问反应页面时设置会话。在下面的示例代码中,我以 facebook 为例

$url = "https://facebook.com" 
$webrequest = Invoke-WebRequest -Uri $url -SessionVariable websession 

Write-Output $websession

$cookies = $websession.Cookies.GetCookies($url) 

# Here, you can output all of $cookies, or you can go through them one by one. 

foreach ($cookie in $cookies) { 
     # You can get cookie specifics, or just use $cookie 
     # This gets each cookie's name and value 
     Write-Host "$($cookie.name) = $($cookie.value)" 
}

(脚本取自https://gallery.technet.microsoft.com/scriptcenter/Getting-Cookies-using-3c373c7e

这不会输出任何 cookie,尽管 FB 会发送 cookie,正如我在浏览器的开发者控制台中看到的那样。如果我在 google.ch 上运行这个脚本,它就可以工作。我还尝试了另一个反应页面,但又一次......不起作用。我在这里缺少什么?

此致

标签: reactjspowershell

解决方案


推荐阅读