c# – Get cookies to use in a C # function

Question:

I use webbrowser for authorization on the site. But on win 10, for some reason, he just refreshes the page, but authorization does not occur. On win 7, everything is fine. I decided to bind cookies immediately when loading the form using the InternetSetCookie function. But just to drive in the keys and cookie values ​​with your hands is not an option, they change there, it seems. So the question is, how can you get cookies from film4smart.net and write them to the InternetSetCookie function? At the moment I'm doing this:

string url = "http://film4smart.net/load/0-0-0-0-1";
InternetSetCookie(url, "0filmcorpsocses", "BLNFuKhrCWiqtamdys6Qy7Ne2Uxhm9JjFaV%5E6LNRNxmLHwoo;");
InternetSetCookie(url, "0filmcorpuispm", "1475931860-0;");
InternetSetCookie(url, "body-class", "st-cyan;");
InternetSetCookie(url, "0filmcorpuzll", "1476100531;");
InternetSetCookie(url, "0filmcorpuCoz", "1QCeH1b4ktFG0Zt;");
InternetSetCookie(url, "0filmcorppPp", "0;");
InternetSetCookie(url, "0filmcorpp2", "0;");
InternetSetCookie(url, "0filmcorppSum", "0;");
InternetSetCookie(url, "0filmcorppA16", "0;");
webBrowser1.Navigate(url);

But it doesn't work that way, because, as I said, cookies are constantly changing. Those. I was logged in for some period, but a couple of hours passed, and all the cookies changed.

I also tried to change the webbrowser mode to ie 11, but it did not help … If you know another way to log in, I will be very grateful for it.

Answer:

It is possible through HttpWebRequest then you will have full control over the requests, but if you need a browser try Selenium there is Edge and Chrome

Scroll to Top