public async Task <bool> Login(string userName, string password) { var loginPage = await client.GetStringAsync("https://twitter.com/login"); var form = WebParser.Parse(loginPage).Where(f => f.Action == "https://twitter.com/sessions").First(); if (form != null) { Dictionary <string, string> postData = new Dictionary <string, string>(); foreach (var input in form.Inputs) { postData[input.Name] = input.Value; } postData["session[username_or_email]"] = userName; postData["session[password]"] = password; postData["redirect_after_login"] = "******"; authenticity_token = postData["authenticity_token"]; HttpContent content = new FormUrlEncodedContent(postData); var result = await client.PostAsync(form.Action, content); string response = await result.Content.ReadAsStringAsync(); return(!response.Contains("https://twitter.com/sessions")); } return(false); }
public OutType Get(string url) { string rawHtml = mWebGetter.Get(url); return(mParser.Parse(rawHtml)); }