使用C#从控制台应用程序登录网站

时间:2018-09-25 23:21:54

标签: c# http web cookies xnet

我正在尝试使用C#从控制台应用程序登录到已知的website,为实现相同目的,我正在使用一个名为xNet的库,而且我还使用Fiddler获得了我需要的所有信息。 / p>

我面临的问题是,当我启动程序时,它只是下载了页面源代码。我已经提供了用于登录的所有信息,但仍然无法正常工作。

这是我用来实现相同功能的代码-

CookieDictionary cookieJar; // Use if you need to get Cookies
        using (var request = new HttpRequest())
        {
            //request.Proxy = HttpProxyClient.Parse("127.0.0.1:8888"); // Fiddler proxy
            cookieJar = new CookieDictionary(); // Only if you need to get Cookies
            request.Cookies = cookieJar; // The request cookies = cookiejar cookies
            request.IgnoreProtocolErrors = true; // Ignore Any errors
            request.KeepAlive = true;
            request.ConnectTimeout = 10000;
            request.AllowAutoRedirect = false;
            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134";
            request.AddParam("email", "danielki887465@gmail.com"); // If it's in WebForms type then use this
            request.AddParam("password", "q7a8z91x2s3w"); // If it's in WebForms type then use this

            request.AddHeader("Origin", "https://www.skipthedishes.com");
            request.AddHeader("Host ", "www.skipthedishes.com"); // Search for the Host
            cookieJar.Add("cto_lwid", "049e61f4-fcdd-4f28-ac53-f1ce13c9cc40"); // Add Cookies to here
            cookieJar.Add("_ga", "GA1.2.1520958558.1537913597"); // Add Cookies to here
            cookieJar.Add("_gid", "GA1.2.73030699.1537913597"); // Add Cookies to here
            cookieJar.Add("__zlcmid", "oZhfa9ad7gHAbO"); // Add Cookies to here
            cookieJar.Add("visid_incap_1014357", "YqrbddCwQkSJaqPK7nCt5LiyqlsAAAAAQkIPAAAAAACAqhyHAWiBEiBwkV2hPw0z9BH0mP7g6o3f"); // Add Cookies to here
            cookieJar.Add("incap_ses_438_1014357", "/6PqWWl0AzRFSmnlnRgUBgG/qlsAAAAAIW6EM2ccKQfZ/hakG+a33A=="); // Add Cookies to here
            cookieJar.Add("incap_ses_484_1014357", "hdyAC6y7Zkmu9/f9FIS3Blq/qlsAAAAAU2zCtEQaMtAsUzONKRnQ0w=="); // Add Cookies to here
            cookieJar.Add("skip_auth", @"""e30\075 | 1537917001 | "); // Add Cookies to here

            request.Referer = "https://www.skipthedishes.com/"; // Search For referer
            HttpResponse respone = request.Post("https://www.skipthedishes.com/user/login/json"); // Just paste the URL Here
            var attempt = request.Post("https://www.skipthedishes.com/user/login/json").ToString(); // Just paste the URL here
            Console.WriteLine(attempt); // Print the Debug and results of the code to see if everything is working
        }
        Console.ReadKey();

我可以从提琴手那里获取Cookie,并使用测试帐户的详细信息。

您能否让我知道我的代码有什么问题,以实现从控制台应用程序登录网站的功能?

0 个答案:

没有答案
相关问题