I am trying to scrape some html from a site. All other urls work but one in particular gives a problem. The url has a dot in, it's not something I can change because it is someone else's site.
string url = "http://blahblah.com/over-under-2.5" // not the actual url!
HtmlWeb htmlWeb = new HtmlWeb();
var document = htmlWeb.Load(url);
It doesn't give any runtime error but the document returned is empty.
Is there any workaround?
Use the Uri
class to create your URL.
Uri uri = new Uri("http://blahblah.com/over-under-2.5");
HtmlWeb htmlWeb = new HtmlWeb();
var page = htmlWeb.Load(uri.AbsoluteUri);
Console.WriteLine(page.DocumentNode.SelectSingleNode("//*[@id=\"currentpage\"]").InnerText);
which will output "BLAH" from the web page.