I'm struggling to write a Windows Service that accesses a website, logs in using stored credentials, and downloads the HTML to parse it. What do you think is the best way to go about this?
You could use the WebClient class.
Here are some examples (it's ASP.NET but the code applies equally to using in a service): Screen Scraping, ViewState, and Authentication using ASP.Net
If you really have to do that (The webserver doesn't provide a webservice), use the HttpWebRequest (http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx) and parse the HTML either with Regex or some html parsing lib.
Or WebClient, of course.
if it's a specific website, it's possible that you can send the required POST data immediately and bypass parsing the login page. HttpWebRequest
or WebClient
are what you need. you need to open a connection, send the post data, and then retrieve your response. a bit more complicated than I feel like going into here :)
for parsing HTML pages, I've had success with HtmlAgilityPack
You can host an IRobotX activex control, and run a web robot to retrieve the page.