ok i might be dumb cause im the only one asking this kind of question since i saw no similar questions but excuse me for that :|. quarantine just keep making me tryna learn more programming languages, got nothin to do. sorry if i kept asking for solutons everytime. cause i've tried researching for it and got nothing.
Anyway, so I tried to retrieve Cookies from a Shopping webpage with System.Net.Http;
which supposed to be having the csrftoken in the Browser cookies. I tried using Python before but I got no cookies retrieved, but for some reason with C#, I got some retrieved. However, I didn't recieve the csrftoken cookie. I think it's because the cookie was based on browser session? :/. I've seen this guy getting his csrftoken, but reading the code is a bit confusing for me. How do I retrieve the csrftoken session cookie?.
This is the code that I'm currently using anyway.
try
{
CookieContainer container = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://shopee.co.id/");
request.Proxy = null;
request.CookieContainer = container;
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36";
request.Referer = "https://shopee.co.id";
request.Headers.Add("authority", "shopee.co.id");
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
foreach (Cookie cookie in response.Cookies)
{
Console.WriteLine("Name =" + cookie.Name);
Console.WriteLine("Value =" + cookie.Value);
Console.WriteLine("Path =" + cookie.Path);
Console.WriteLine("Domain =" + cookie.Domain);
}
}
}