Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:21:13+00:00 2026-06-10T06:21:13+00:00

I have a problem with encoding while trying to get html from google.com. Please,

  • 0

I have a problem with encoding while trying to get html from google.com. Please, give me a advice how to resolve this problem. Thanks a lot.

public string Html
    {
        get
        {
            try
            {
                var request = WebRequest.Create(Url) as HttpWebRequest;
                request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1,gzip(gfe)";
                if (request != null)
                {
                    var response = request.GetResponse() as HttpWebResponse;
                    if (response != null)
                    {
                        string Charset = response.CharacterSet;
                        Encoding encoding = Encoding.GetEncoding(Charset);
                        var sr = new StreamReader(response.GetResponseStream(), encoding);
                        return sr.ReadToEnd();
                    }
                }
                return string.Format("Could not create object HttpWebRequest for '{0}'", Url);
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
    }

Here is an image as well:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:21:15+00:00Added an answer on June 10, 2026 at 6:21 am

    The problem you are facing is because for some reason Google doesn’t send out any encoding information in the headers. If you inspect the headers using the links below (specifically the Content-Type header) and compare the first one (which is from your image) to the second one you will see that the first one is missing some vital information.

    http://web-sniffer.net/?url=http://www.google.com.ua/intl/ils/ads/

    http://web-sniffer.net/?url=http://www.google.de/

    What you need to do here is to first parse the HTML that is returned and look for a <meta>-element which specifies the encoding and then redecode the stream you are getting with that new information. Depending on what you are doing with the HTML afterwards you might want to look into http://htmlagilitypack.codeplex.com/ as a great library for working with HTML or just write a regular expression to extract the encoding (though I would really recommend the first alternative instead).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to test the API from ankoder.com and have problem on the
I have some problem while trying to use the schemagen tool from JAXB library
I have a problem while trying to batch convert the encoding of some files
I have a problem with utf-8 encoding in primefaces 3. but with this (adding
HI Guys, I have following problem. I'm trying to connect from my Iphone app
I have a very weird problem while trying to pass and SQL query using
I have encountered a problem when trying to select data from a table in
My team and I have this nasty problem with parsing a string received from
I am trying to get all the data from http://www.nationwide.com/locator/home/index.x?lineOfBusiness=insurance_agent&locatorhome=fromhome&language= every state listed there.
I have been struggling with encoding problems in MySQL for a while. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.