T
T
thinkkaka2021-01-13 19:07:43
Character encoding
thinkkaka, 2021-01-13 19:07:43

How to change the encoding "1251" when parsing a site?

I want to parse data from the site, but all Russian letters turn out to be either an underscore "_" or a question mark in a rhombus "�" (depending on the version of Visual Studio). The site's source code contains the encoding charset="windows-1251" .

How to change the encoding to the standard or what encoding is needed?

my code:

Imports System.IO
Imports System.Net

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim request As System.Net.HttpWebRequest
        Dim response As System.Net.HttpWebResponse = Nothing
        Dim reader As StreamReader

        System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12

        request = DirectCast(System.Net.WebRequest.Create("https://filmix.cloud/komedia/98757-kung-fyuri-kung-fury-2015.html"), System.Net.HttpWebRequest)

        request.UserAgent = "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0"
        response = DirectCast(request.GetResponse(), System.Net.HttpWebResponse)
        reader = New StreamReader(response.GetResponseStream())

        RichTextBox1.Text = reader.ReadToEnd()
       
    End Sub

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question