Visual Basic.NET - descargar html

 
Vista:

descargar html

Publicado por flashnet (6 intervenciones) el 30/07/2011 19:10:24
Hola a todos/todas,
tengo el siguiente problema que al descargarme el html de una web no me salen codificados las ñ ni acentos, a ver si alguien me puede echar una mano. saludos

El codígo:

Private Function LeerHTML(ByVal url As String) As String
Try
Dim resultado As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url)
DirectCast(objRequest, System.Net.HttpWebRequest).UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.38) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.26529)"
' DirectCast(objRequest, System.Net.HttpWebRequest).ContentType = "text/html; charset=UTF-8"


Dim encode As Encoding = System.Text.Encoding.GetEncoding("iso-8859-1")

objResponse = objRequest.GetResponse()
Using sr As New StreamReader(objResponse.GetResponseStream(), encode)
resultado = sr.ReadToEnd()

sr.Close()
End Using
Return resultado
Catch ex As Exception
'lblStatus.Text = ex.Message
Return ex.Message.ToString
Exit Function
End Try
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder