I'm trying to get the HTML source as string from the following website:
https://physics.nist.gov/cgi-bin/cuu/CCValue?mal|ShowSecond=Browse&First=malc2
But when I'm using WebClient
in C#:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebClient client = new WebClient();
string s = client.DownloadString("https://physics.nist.gov/cgi-bin/cuu/CCValue?mal|ShowSecond=Browse&First=malc2");
I'm getting back you have supplied an ill-formed request
from the website and not the correlation coefficient I'm looking for.
I took as well a look at the following question How to post data to specific URL using WebClient in C# but it didn't helped me.
I think the problem has to do with the |
character in the URL. If you click on the link above it doesn't work because the |
is replaced by %7C
.
System.Diagnostics.Process.Start(url)
opens the correct page in a browser.
See https://dotnetfiddle.net/wAYWEu
Update
Using Wireshark and switching to http I can see that the |
character gets replaced by %7C
.
144 2.241432 10.131.36.167 195.176.26.193 HTTP 253 GET http://physics.nist.gov/cgi-bin/cuu/CCValue?mal%7CShowSecond=Browse&First=malc2 HTTP/1.1
How can I avoid that?