I'm trying to parse download pages from www.mediafire.com, but i really often get a System.Net.WebException
with the following message, when i try to load a page to a HtmlDocument
:
The server committed a protocol violation. Section=ResponseStatusLine
This is my code:
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = null;
string url = www.mediafire.com/?abcdefghijkl //There are many different links
try
{
doc = web.Load(url); //From 30 links, usually only 10 load properly
}
catch (WebException)
{
}
Any ideas why only 10 of 30 links work (the links change everytime, because my program is a "search engine") and how i can resolve the problem?
When i load those sites in my browser, everything works fine.
I've tried to add the following lines to my app.config, but that doesn't help either
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>