Method HttpContent.ReadAsStringAsync() returns invalid html code. How it can be?Can HTML checkboxes be set to readonly?How can I know which radio button is selected via jQuery?How to use HTML Agility packHow can I select an element by name with jQuery?How to mark a method as obsolete or deprecated?What characters can be used for up/down triangle (arrow without stem) for display in HTML?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?How to create a checkbox with a clickable label?How do I reformat HTML code using Sublime Text 2?
Why radial coordinate of a particle must decrease continuously once it is inside the Schwarzschild radius?
Sci-fi change: Too much or Not enough
Can an Oathbreaker Paladin reform and choose a different Paladin subclass?
Can a US President, after impeachment and removal, be re-elected or re-appointed?
(3 of 11: Akari) What is Pyramid Cult's Favorite Car?
How did the Axis intend to hold the Caucasus?
Is there a way to know the composition of a Team GO Rocket before going into the fight?
What container to use to store developer concentrate?
Struggling with cyclical dependancies in unit tests
Desktop app status bar: Notification vs error message
Why did Windows 95 crash the whole system but newer Windows only crashed programs?
Compound Word Neologism
Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?
2 weeks and a tight budget to prepare for Z-day. How long can I hunker down?
Is it error of law to judge on less relevant case law when there is much more relevant one?
How do you pronounce "Hain"?
If Trump gets impeached, how long would Pence be president?
Are there any unpublished Iain M. Banks short stories?
reconstruction filter - How does it actually work?
Is there an antonym for "spicy" or "hot" regarding food (NOT "seasoned" but "spicy")?
When I cite content from a book, should I say "section 2.3.2.1 of book... " or "section 2.3.2.1 of `the` book ..."?
Why not notify faculty candidates of the position being filled?
Why isn't there any 9.5 digit multimeter or higher?
How can I kill my goat?
Method HttpContent.ReadAsStringAsync() returns invalid html code. How it can be?
Can HTML checkboxes be set to readonly?How can I know which radio button is selected via jQuery?How to use HTML Agility packHow can I select an element by name with jQuery?How to mark a method as obsolete or deprecated?What characters can be used for up/down triangle (arrow without stem) for display in HTML?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?How to create a checkbox with a clickable label?How do I reformat HTML code using Sublime Text 2?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Here is some code,to request html-code from url.
var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;
if (response != null && response.StatusCode == HttpStatusCode.OK)
sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code
SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.
Also, here is some proofs. First image - number of character in browser-html code
... and in program-html code
I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:
FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);
c# html dotnet-httpclient httpcontent
add a comment |
Here is some code,to request html-code from url.
var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;
if (response != null && response.StatusCode == HttpStatusCode.OK)
sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code
SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.
Also, here is some proofs. First image - number of character in browser-html code
... and in program-html code
I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:
FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);
c# html dotnet-httpclient httpcontent
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59
add a comment |
Here is some code,to request html-code from url.
var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;
if (response != null && response.StatusCode == HttpStatusCode.OK)
sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code
SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.
Also, here is some proofs. First image - number of character in browser-html code
... and in program-html code
I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:
FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);
c# html dotnet-httpclient httpcontent
Here is some code,to request html-code from url.
var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;
if (response != null && response.StatusCode == HttpStatusCode.OK)
sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code
SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.
Also, here is some proofs. First image - number of character in browser-html code
... and in program-html code
I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:
FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);
c# html dotnet-httpclient httpcontent
c# html dotnet-httpclient httpcontent
edited Mar 26 at 19:41
Amy
22.9k19 gold badges76 silver badges134 bronze badges
22.9k19 gold badges76 silver badges134 bronze badges
asked Mar 26 at 19:19
Mister CrabsMister Crabs
113 bronze badges
113 bronze badges
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59
add a comment |
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364768%2fmethod-httpcontent-readasstringasync-returns-invalid-html-code-how-it-can-be%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364768%2fmethod-httpcontent-readasstringasync-returns-invalid-html-code-how-it-can-be%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?
– mason
Mar 26 at 19:27
HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.
– DSakura
Mar 26 at 22:29
Hmmm, ok. But how can i load the page like in the browser,and get correct html code?
– Mister Crabs
Mar 26 at 23:23
@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?
– DSakura
Mar 27 at 19:59