jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.16k stars 250 forks source link

CQ.CreateFromUrl error #149

Closed prcomm closed 10 years ago

prcomm commented 10 years ago

CreateFromUrl causes WebException while loading web-pages which demand of cookies accepting (ex.: http://www.lscompany.spb.ru). Simply solved by appending of Net.CookieContainer to the underlying HttpWebRequest (code example: http://social.msdn.microsoft.com/Forums/vstudio/en-US/d1d3c41c-bf70-447a-bbb7-8bb09a2f6ca6/making-requests-using-webclient-and-security-tokens?forum=Geneva).

jamietre commented 10 years ago

You can access the inner HttpWebRequest using a construct like this:

https://github.com/jamietre/CsQuery/blob/master/documentation/createfromurl.md#accessing-the-httpwebrequest

It should be easy enough to create a wrapper or extension method to incorporate this if you want to do so for all requests. Generally speaking I don't intend to build a lot of capabilities onto CreateFromUrl since there are any number of things people might want to customize or refine such as this.