vb.net 读取网页源码(支持各种编码)

来源:互联网 发布:linux下wget命令安装 编辑:程序博客网 时间:2024/05/22 15:09

 Public Function LobDotCn(ByVal url_Link As String, ByVal IsGb2312 As Boolean)

        On Error Resume Next
        Dim XmlHttp As Object
        XmlHttp = CreateObject("Microsoft.XMLHttp")
        XmlHttp.Open("POST", url_Link, False)
        XmlHttp.Send()
        Dim WebContent As Object
        Dim Str_WebContent As String
        If IsGb2312 Then
            WebContent = XmlHttp.ResponseBody
            Str_WebContent = System.Text.Encoding.Default.GetString(WebContent)
        Else
            WebContent = XmlHttp.ResponseText
            Str_WebContent = WebContent.ToString
        End If
        XmlHttp = Nothing
        LobDotCn = Str_WebContent

    End Function

 

 

第二个参数 为编码转化参数

原创粉丝点击