Skip to content

Instantly share code, notes, and snippets.

@fjeldstad
Created July 8, 2011 12:31
Show Gist options
  • Save fjeldstad/1071730 to your computer and use it in GitHub Desktop.
Save fjeldstad/1071730 to your computer and use it in GitHub Desktop.
private static HtmlDocument GetHtmlDocument(string url)
{
var page = new HtmlDocument
{
OptionOutputAsXml = true
};
HtmlNode.ElementsFlags.Remove("option");
// Fetch and load HTML document (default gym selected)
var request = (HttpWebRequest)HttpWebRequest.Create(url);
request.UserAgent = UserAgent;
var response = (HttpWebResponse)request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream(), true))
{
page.LoadHtml(reader.ReadToEnd());
}
return page;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment