In my C# code, I want to use only server-side code to fetch the content of the page here:
Problem is, that the dynamic part is appended upon page load, so today it looks like this, but tomorrow it will look different.
https://1962ordo.today/day/sts-cosmas-and-damian-2-2-4/
I want to fetch the text only of the container
tag, and nothing else, but would like to keep the <br>
tags in place.
I've tried using a streamreader with SSL capabilities, but it doesn't seem to work correctly.
In the end, I need a simple html string that I can load into my page.
So far, this is what I've come up with; it tries to load the content, but keeps trying to load and never resolves (I have it in the asp.net page_load part):
protected void Page_Load(object sender, EventArgs e) {
string ordourl;
ordourl = "https://1962ordo.today";
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
using (WebClient webClient = new WebClient()) {
webClient.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)";
webClient.Headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
webClient.Headers["Accept-Language"] = "en-us,en;q=0.5";
webClient.Headers["Accept-Encoding"] = "gzip,deflate";
webClient.Headers["Accept-Charset"] = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
StreamReader sr = new StreamReader(webClient.OpenRead(ordourl));
string results = sr.ReadToEnd();
div_ordo.InnerHtml = results;
};
}
If I use InnerText
instead of InnerHtml
, it loads into the page's <div>
the underlying html, but amoungst that, none of it is the actual data for the day. The Streamreader isn't getting the data which is the result of the actual page's final load. It's just getting the actual page's html. I need the code to wait for the database info to be loaded into that page and display the final results, not the initial page.
I've tried this, and it does exactly the same thing:
protected void Page_Load(object sender, EventArgs e) {
string ordourl;
ordourl = "https://1962ordo.today";
string ordotext;
ordotext = "";
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
WebRequest request = WebRequest.Create(ordourl);
WebResponse response = request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
ordotext = reader.ReadToEnd();
div_ordo.InnerText = ordotext;
reader.Close();
}
response.Close();
}