五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動態(tài)

powershell網(wǎng)絡(luò)蜘蛛解決亂碼問題

發(fā)布日期:2022-01-22 00:37 | 文章來源:CSDN

抓?。ㄅ廊。┚W(wǎng)上信息的腳本程序,俗稱網(wǎng)絡(luò)蜘蛛。
powershell中自帶了這樣的兩個命令,【Invoke-WebRequest】和【Invoke-RestMethod】,但這兩個命令有時候會亂碼。

現(xiàn)在轉(zhuǎn)帖分享, 某個【歪果仁】寫的腳本。來源于 墻外出處: https://gist.github.com/angel-vladov/9482676

核心代碼

function Read-HtmlPage {
param ([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][String] $Uri)
# Invoke-WebRequest and Invoke-RestMethod can't work properly with UTF-8 Response so we need to do things this way.
[Net.HttpWebRequest]$WebRequest = [Net.WebRequest]::Create($Uri)
[Net.HttpWebResponse]$WebResponse = $WebRequest.GetResponse()
$Reader = New-Object IO.StreamReader($WebResponse.GetResponseStream())
$Response = $Reader.ReadToEnd()
$Reader.Close()
# Create the document class
[mshtml.HTMLDocumentClass] $Doc = New-Object -com "HTMLFILE"
$Doc.IHTMLDocument2_write($Response)
# Returns a HTMLDocumentClass instance just like Invoke-WebRequest ParsedHtml
$Doc
#powershell 傳教士 轉(zhuǎn)帖并修改的文章 2016-01-01, 允許再次轉(zhuǎn)載,但必須保留名字和出處,否則追究法律責任
}

原文函數(shù)

function Read-HtmlPage {
  param ([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][String] $Uri)
  # Invoke-WebRequest and Invoke-RestMethod can't work properly with UTF-8 Response so we need to do things this way.
  [Net.HttpWebRequest]$WebRequest = [Net.WebRequest]::Create($Uri)
  [Net.HttpWebResponse]$WebResponse = $WebRequest.GetResponse()
  $Reader = New-Object IO.StreamReader($WebResponse.GetResponseStream())
  $Response = $Reader.ReadToEnd()
  $Reader.Close()
  # Create the document class
  [mshtml.HTMLDocumentClass] $Doc = New-Object -com "HTMLFILE"
  $Doc.IHTMLDocument2_write($Response)
  
  # Returns a HTMLDocumentClass instance just like Invoke-WebRequest ParsedHtml
  $Doc
}

PowerShell function you can use for reading UTF8 encoded HTML pages content. The built in Invoke-WebRequest and Invoke-RestMethod fail miserably.

版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部