从Powershell生成HTTP状态代码

时间:2019-03-14 04:27:18

标签: powershell http networking web-scraping http-status-codes

generated状态代码如何:

$ pwsh bar.ps1 
http://google.com
OK
200

$ cat bar.ps1 
$url = 'http://google.com'

Write-Output $url

$req = [system.Net.WebRequest]::Create($url)

try {
    $res = $req.GetResponse()
} 
catch [System.Net.WebException] {
    $res = $_.Exception.Response
}

$res.StatusCode
#OK

[int]$res.StatusCode
#200

与实际浏览器将收到的状态码完全不同吗?

很明显,这并不是产生实际的浏览器。但是,除了用户代理字符串之外,这还以什么方式与实际的Web浏览器有所不同?

我在思考along the linespingICMPTCPUDP略有不同。

0 个答案:

没有答案
相关问题