How to download to a complete web page with VB.NET

zhaozj2021-02-16  71

How to download the web page with VB.NET ????

??? I found a lot of questions about web downloads on the web but I can't fully get the content of the web page. The following functions solved this problem. Private function getSource (Byval URL AS String) AS String Try Dim httpreq as system.Net.httpwebRequest 'HttpWebRequest class provides support to the properties and methods defined in WebRequest, also enabled additional properties that make users interact with server using HTTP And the method is supported. The DIM HTTPRESP AS System.Net.httpwebResponse 'HTTPWebResponse class is used to generate an HTTP independent client application that sends HTTP requests and receives HTTP'. Dim httpURL As New System.Uri (url) httpReq = CType (WebRequest.Create (httpURL), HttpWebRequest) httpReq.Method = "GET" httpResp = CType (httpReq.GetResponse (), HttpWebResponse) Dim reader As StreamReader = _ New StreamReader (httpresp.getresponsestream, system.text.Encoding.getencoding ("GB2312")) 'If Chinese, set the encoded format to "GB2312". Dim Resphtml As String = Reader.ReadToend () 'Resphtml is the web source Return Resphtml httpresp.close () Catch e as exception console.writeline ("GetSource Problem: {0}, {1}", E.MESSAGE, URL ) END TRY END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-16760.html

New Post(0)