public void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null) { if (nguoigui.Cookie == null) { throw new Exception("Thiếu cookie"); } string dataGui = string.Format("fuid={0}&tuid={1}&message={2}&from_to={0}-{1}", nguoigui.Id, nguoinhan.Id, noidung); var responseGuiTin = RequestToWeb.POST(new Uri("http://likeyou.vn/messages/send-message"), nguoigui.Cookie, dataGui, false); string phanHoi = Uri.UnescapeDataString(RequestToWeb.ReadStream(responseGuiTin)); var header3 = RequestToWeb.ReadHeader(responseGuiTin.Headers); if (phanHoi == "\n\n 1") { nguoinhan.TrangThai = nguoigui.TaiKhoan; System.Threading.Tasks.Task.Run(() => { //Để tự gửi lại 1 tìn => mới lưu vào hộp thư đến dataGui = string.Format("fuid={1}&tuid={0}&from_to={1}-{0}", nguoigui.Id, nguoinhan.Id); var gg = RequestToWeb.POST(new Uri("http://likeyou.vn/messages/send-message"), nguoigui.Cookie, dataGui, true); }); } else { nguoinhan.TrangThai = "Gửi lỗi"; } }
public static void Test() { ThongTinTaiKhoan tk = new ThongTinTaiKhoan(); tk.Cookie = new CookieContainer(); var cookieBanDauResponse = RequestToWeb.GET(new Uri("http://media.likeyou.vn/"), true, false, tk.Cookie); tk.TaiKhoan = "*****@*****.**"; tk.MatKhau = "*****@*****.**"; string data = string.Format("name={0}&pass={1}&remember_me=1&form_id=user_login", tk.TaiKhoan, tk.MatKhau); var dangNhapResponse = RequestToWeb.POST(new Uri("http://likeyou.vn/vi/user?destination=user"), tk.Cookie, data, false, true); string res = RequestToWeb.ReadStream(dangNhapResponse); var loginHeader = RequestToWeb.ReadHeader(dangNhapResponse.Headers); if ((dangNhapResponse as HttpWebResponse).StatusCode == HttpStatusCode.Found) { if (dangNhapResponse.ResponseUri != null && dangNhapResponse.ResponseUri.Query != null && dangNhapResponse.ResponseUri.Query.Contains("user="******"Đang nhập thành công"; } else { tk.TrangThai = "Đang nhập thất bại"; } var guiTin = RequestToWeb.POST(new Uri("http://likeyou.vn/messages/send-message"), tk.Cookie, "fuid=636691&tuid=636421&message=Không có id người gửi", false); string s3 = Uri.UnescapeDataString(RequestToWeb.ReadStream(guiTin)); var header3 = RequestToWeb.ReadHeader(guiTin.Headers); }
public static void Test() { ThongTinTaiKhoan tk = new ThongTinTaiKhoan(); tk.TaiKhoan = "ngochoaitn"; tk.MatKhau = "noongngocj"; tk.Cookie = new CookieContainer(); string dangNhap_data = string.Format("username={0}&password={1}&nonxpcookie=1&login=Login&islogin=1", tk.TaiKhoan, tk.MatKhau); var dangNhap_Response = RequestToWeb.POST(new Uri("http://www.timbangai.com/timbangai/account/login/"), tk.Cookie, dangNhap_data, false); string dangNhap_string = RequestToWeb.ReadStream(dangNhap_Response); var dangNhap_Header = RequestToWeb.ReadHeader(dangNhap_Response.Headers); if (dangNhap_string == "") { tk.TrangThai = "Đang nhập thành công"; } else { tk.TrangThai = "Sai tài khoản hoặc mật khẩu"; } //Gửi thư ThongTinTaiKhoan nguoigui = tk; ThongTinTaiKhoan nguoinhan = new ThongTinTaiKhoan() { TenHienThi = "asbirine", Url = "http://www.timbangai.com/timbangai/asbirine" }; if (string.IsNullOrEmpty(tk.Id)) { //Lấy thông tin tài khoản nhận thư var thongTinNguoiNhanThu_Response = RequestToWeb.GET(new Uri(nguoinhan.Url), false); string thongTinNguoiNhanThu_string = RequestToWeb.ReadStream(thongTinNguoiNhanThu_Response); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml(thongTinNguoiNhanThu_string); var thongTinNguoiNhanThu_message = document.DocumentNode.Descendants("li").Where(div => div.HasClass("message")).FirstOrDefault(); string thongTinNguoiNhanThu_Url = thongTinNguoiNhanThu_message.QuerySelector("a").GetAttributeValue("href", ""); nguoinhan.Id = thongTinNguoiNhanThu_Url.Split('/')[7]; } string noidung = "Nội dung tự động"; string chude = "chủ đề tự động"; string guiThu_data = string.Format("subject={0}&body={1}&submit=Gởi&ismessage=1", chude, noidung); var guiThu_Response = RequestToWeb.POST(new Uri(string.Format("http://www.timbangai.com/timbangai/account/messages/compose/{0}", nguoinhan.Id)), nguoigui.Cookie, guiThu_data, false); string guiThu_string = RequestToWeb.ReadStream(guiThu_Response); if (guiThu_string == "") { nguoinhan.TrangThai = tk.TaiKhoan; } else { nguoinhan.TrangThai = "Gửi lỗi"; } }
public static void Test() { #region Đang nhập, gửi tin ThongTinTaiKhoan tk = new ThongTinTaiKhoan(); tk.Cookie = new CookieContainer(); tk.TaiKhoan = "ngochoaitn"; tk.MatKhau = "noongngocj"; string dangNhapData = string.Format("username={0}&password={1}&btn_submit=ĐĂNG NHẬP", tk.TaiKhoan, tk.MatKhau); var dangNhapResponse = RequestToWeb.POST(new Uri("https://henhoketban.vn/login.php"), tk.Cookie, dangNhapData, false); string dangNhapStringResponse = RequestToWeb.ReadStream(dangNhapResponse); var dangNhapHeader = RequestToWeb.ReadHeader(dangNhapResponse.Headers); if (dangNhapStringResponse.Contains("ĐĂNG NHẬP THÀNH CÔNG")) { //Đi lấy thông tin tài khoản var layThongTinResponse = RequestToWeb.GET(new Uri("https://henhoketban.vn/index.php"), false, false, tk.Cookie); string layThongTinStringResponse = RequestToWeb.ReadStream(layThongTinResponse); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml(layThongTinStringResponse); string duongDan = document.DocumentNode.QuerySelectorAll("div#top > div > div > font > a").FirstOrDefault().GetAttributeValue("href", ""); tk.Id = duongDan.Split('=')[1]; //Lấy tên hiển thị var tenHienThiResponse = RequestToWeb.GET(new Uri(duongDan), false); string tenHienThiStringResponse = RequestToWeb.ReadStream(tenHienThiResponse); document.LoadHtml(tenHienThiStringResponse); tk.TenHienThi = document.DocumentNode.QuerySelector("h1 > font").InnerText.Split('|')[1].Trim(); //Gửi tin nhắn ThongTinTaiKhoan tknhan = new ThongTinTaiKhoan() { Id = "10454", TenHienThi = "Lan" }; string tieuDe = "Tiêu đề xxxxxxxx"; string noidung = "Nội dung xxxxxxxxx"; string guiData = string.Format("idgui={0}&idnhan={1}&tennguoigui={2}&tennguoinhan=AutoSend->{3}&tieude={4}&noidung={5}&btn_submit=GỬI TIN NHẮN", tk.Id, tknhan.Id, tk.TenHienThi, tknhan.TenHienThi, tieuDe, noidung); var guiTinResponse = RequestToWeb.POST(new Uri("https://henhoketban.vn/guithu.php"), tk.Cookie, guiData, false); string guiStringResponse = RequestToWeb.ReadStream(guiTinResponse); if (guiStringResponse.Contains("GỬI TIN NHẮN THÀNH CÔNG.")) { tknhan.TrangThai = tk.TaiKhoan; } else { tknhan.TrangThai = "Gửi lỗi"; } } #endregion }
public void DangNhap(ref ThongTinTaiKhoan tk) { tk.Cookie = new CookieContainer(); string dangNhap_data = string.Format("username={0}&password={1}&nonxpcookie=1&login=Login&islogin=1", tk.TaiKhoan, tk.MatKhau); var dangNhap_Response = RequestToWeb.POST(new Uri("http://www.timbangai.com/timbangai/account/login/"), tk.Cookie, dangNhap_data, false); string dangNhap_string = RequestToWeb.ReadStream(dangNhap_Response); var dangNhap_Header = RequestToWeb.ReadHeader(dangNhap_Response.Headers); if (dangNhap_string == "") { tk.TrangThai = "Đang nhập thành công"; tk.ChoPhepGuiNhan = true; } else { tk.TrangThai = "Sai tài khoản hoặc mật khẩu"; } }
public void DangNhap(ref ThongTinTaiKhoan tk) { tk.Cookie = new CookieContainer(); string dangNhapData = string.Format("username={0}&password={1}&btn_submit=ĐĂNG NHẬP", tk.TaiKhoan, tk.MatKhau); var dangNhapResponse = RequestToWeb.POST(new Uri("https://henhoketban.vn/login.php"), tk.Cookie, dangNhapData, false); string dangNhapStringResponse = RequestToWeb.ReadStream(dangNhapResponse); var dangNhapHeader = RequestToWeb.ReadHeader(dangNhapResponse.Headers); if (dangNhapStringResponse?.Contains("ĐĂNG NHẬP THÀNH CÔNG") ?? false) { tk.TrangThai = "Đăng nhập thành công"; tk.ChoPhepGuiNhan = true; #region Lấy Id, tên hiển thị dùng để gửi thư try { HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); #region Lấy ID var layThongTin_Id_Response = RequestToWeb.GET(new Uri("https://henhoketban.vn/index.php"), false, false, tk.Cookie); string layThongTinStringResponse = RequestToWeb.ReadStream(layThongTin_Id_Response); document.LoadHtml(layThongTinStringResponse); string duongDan = document.DocumentNode.QuerySelectorAll("div#top > div > div > font > a").FirstOrDefault().GetAttributeValue("href", ""); tk.Id = duongDan.Split('=')[1]; tk.Url = duongDan; #endregion #region Lấy tên hiển thị var tenHienThi_Response = RequestToWeb.GET(new Uri(duongDan), false); string tenHienThiStringResponse = RequestToWeb.ReadStream(tenHienThi_Response); document.LoadHtml(tenHienThiStringResponse); tk.TenHienThi = document.DocumentNode.QuerySelector("h1 > font").InnerText.Split('|')[1].Trim(); #endregion } catch { } #endregion } }
public void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null) { if (nguoigui.Cookie == null) { throw new Exception("Thiếu cookie"); } tieude = tieude.Split('(')[0].Trim(); bool dungTieude = false; for (int i = 1; i <= 10; i++) { if (tieude == string.Format("default_{0}", i)) { dungTieude = true; break; } } if (!dungTieude) { throw new Exception("Vui lòng chọn tiêu đề như gợi ý: default_<số từ 1 đến 10>\nVí dụ: default_1"); } string data = string.Format("memberid={0}&subject={1}&body={2}&cssSuffix=sm&subjectChanged=false&replyID=0&mailsInThread=0&imbraconsent=0", nguoinhan.Id, tieude, Uri.EscapeDataString(noidung)); var response = RequestToWeb.POST2(new Uri("https://www.vietnamcupid.com/vi/mail/sendEmail?ajaxMode=false"), nguoigui.Cookie, data, false, false, "application/x-www-form-urlencoded; charset=UTF-8"); var headers = RequestToWeb.ReadHeader(response); nguoinhan.TrangThai = nguoigui.TaiKhoan; using (var sr = new StreamReader(response.GetResponseStream())) { string stringResponse = sr.ReadToEnd(); string noidung1 = noidung.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]; if (!stringResponse.Contains(noidung1)) { nguoinhan.TrangThai = "Gửi lỗi\n(không nhận tin nhắn cùng giới hoặc đã quá giới hạn gửi)"; } } }
public IEnumerable <ThongTinTaiKhoan> TimKiem(ThongTinTimKiem param) { #region Tạo request NameValueCollection formData = new NameValueCollection(); formData.Add("type_id", "members"); formData.Add("gender2", "1"); formData.Add("gender1", param.GioiTinh.ToString()); formData.Add("age_from", param.TuTuoi.ToString()); formData.Add("age_to", param.DenTuoi.ToString()); formData.Add("country", "212"); formData.Add("city", param.NoiO.ToString()); if (param.HonNhan.FirstOrDefault().Id.ToString() != "-1") { formData.Add("livingsituation[]", string.Format("{0}", string.Join("&livingsituation[]=", param.HonNhan.Select(p => p.Id.ToString())))); } formData.Add("username", ""); formData.Add("online_only", "0"); formData.Add("pictures_only", "0"); formData.Add("display_type", "1"); formData.Add("search_save", ""); formData.Add("submit", "Gởi"); formData.Add("issearch", "1"); string timKiem_data = formData.ConvertToUrlEncode(); var timKiem_Response = RequestToWeb.POST(new Uri("http://www.timbangai.com/timbangai/search/advanced/"), null, timKiem_data, false, false); var headers = RequestToWeb.ReadHeader(timKiem_Response); string timKiem_string = RequestToWeb.ReadStream(timKiem_Response); string timKiem_location = timKiem_Response.Headers[HttpResponseHeader.Location]; #endregion if ((timKiem_Response as HttpWebResponse).StatusCode == HttpStatusCode.Found) { int page = 1; while (true) { string timKiem_link = string.Format("{0}{1}", timKiem_location, page); timKiem_Response = RequestToWeb.GET(new Uri(timKiem_link), false); timKiem_string = RequestToWeb.ReadStream(timKiem_Response); //string timKiem_string = File.ReadAllText("DataHtmlTest.txt"); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml(HttpUtility.HtmlDecode(timKiem_string)); var bangKetQua = document.DocumentNode.QuerySelectorAll("div#content").FirstOrDefault(); var danhSachKetQua = bangKetQua.Descendants("div").Where(div => div.HasClass("image")); if (danhSachKetQua.Count() == 0) { break; } foreach (var kq in danhSachKetQua) { ThongTinTaiKhoan tk = new ThongTinTaiKhoan(); var ten_tuoi = kq.InnerText.Trim().Split(','); tk.TenHienThi = ten_tuoi[0]; tk.Tuoi = ten_tuoi[ten_tuoi.Count() - 1].ConvertToInt32(); tk.Url = kq.QuerySelector("a").GetAttributeValue("href", ""); tk.GioiTinh = param.OtherParam[0].ToString(); tk.TinhTrangHonNhan = param.OtherParam[1].ToString(); #region Lấy ID Task.Run( () => { var thongTinNguoiNhanThu_Response = RequestToWeb.GET(new Uri(tk.Url), false); string thongTinNguoiNhanThu_string = RequestToWeb.ReadStream(thongTinNguoiNhanThu_Response); HtmlAgilityPack.HtmlDocument thongTinNguoiNhanThu_document = new HtmlAgilityPack.HtmlDocument(); if (!string.IsNullOrEmpty(thongTinNguoiNhanThu_string)) { thongTinNguoiNhanThu_document.LoadHtml(thongTinNguoiNhanThu_string); var thongTinNguoiNhanThu_message = thongTinNguoiNhanThu_document.DocumentNode.Descendants("li").Where(div => div.HasClass("message")).FirstOrDefault(); string thongTinNguoiNhanThu_Url = thongTinNguoiNhanThu_message.QuerySelector("a").GetAttributeValue("href", ""); tk.Id = thongTinNguoiNhanThu_Url.Split('/')[7]; } }); #endregion yield return(tk); if (param.DungTimKiem) { break; } } if (param.DungTimKiem) { break; } page++; } } }
public static void Test() { #region Logout RequestToWeb.GET(new Uri("https://badoo.com/profile/logout"), true); //HttpWebRequest logoutRequest = WebRequest.CreateHttp("https://badoo.com/profile/logout"); //logoutRequest.Method = "GET"; //var logoutResponse = logoutRequest.GetResponse(); #endregion #region Login CookieContainer loginCookie = new CookieContainer(); HttpWebRequest loginRequest1 = WebRequest.CreateHttp("https://badoo.com/signin"); loginRequest1.CookieContainer = loginCookie; loginRequest1.Method = "GET"; loginRequest1.AllowAutoRedirect = true; loginRequest1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/64.4.142 Chrome/58.4.3029.142 Safari/537.36"; loginRequest1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; //loginRequest1.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, sdch, br"); loginRequest1.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8,vi;q=0.6"); loginRequest1.KeepAlive = true; loginRequest1.Headers.Add("DNT", "1"); loginRequest1.Headers.Add("Upgrade-Insecure-Requests", "1"); //using (StreamWriter sw = new StreamWriter(loginRequest1.GetRequestStream())) //{ // string data = File.ReadAllLines("DataHtmlTest.txt")[0]; // sw.Write(data); // sw.Close(); //} var loginRequest1Header = RequestToWeb.ReadHeader(loginRequest1.Headers); var loginResponse1 = loginRequest1.GetResponse(); string sLoginCookie = loginResponse1.Headers[HttpResponseHeader.SetCookie]; string sCookie1 = loginRequest1.Headers[HttpRequestHeader.Cookie]; string sLoginLoc1 = loginResponse1.Headers[HttpResponseHeader.Location]; var loginHeader1 = RequestToWeb.ReadHeader(loginResponse1.Headers); string logginS1 = ""; using (StreamReader sr = new StreamReader(loginResponse1.GetResponseStream())) { logginS1 = sr.ReadToEnd(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Bước 2 HttpWebRequest loginRequestB2 = WebRequest.CreateHttp("https://badoo.com/api.phtml?SERVER_APP_STARTUP"); loginRequestB2.CookieContainer = loginCookie; loginRequestB2.Method = "POST"; loginRequestB2.AllowAutoRedirect = true; loginRequestB2.ContentType = "json"; loginRequestB2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/64.4.142 Chrome/58.4.3029.142 Safari/537.36"; loginRequestB2.KeepAlive = true; //loginRequest2.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br"); loginRequestB2.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8,vi;q=0.6"); loginRequestB2.Referer = "https://badoo.com/signin"; loginRequestB2.Headers.Add("X-Session-id", sLoginCookie.Split(new string[] { "s2=", ";" }, StringSplitOptions.RemoveEmptyEntries)[0]); loginRequestB2.Headers.Add("X-Message-type:2"); int indexIfDeviceId = sLoginCookie.IndexOf("device_id"); string deviceId = sLoginCookie.Substring(indexIfDeviceId); deviceId = deviceId.Substring(10); deviceId = deviceId.Substring(0, deviceId.IndexOf(";")); using (StreamWriter sw = new StreamWriter(loginRequestB2.GetRequestStream())) { string data = File.ReadAllLines("BadooTest.txt")[1].Replace("_DEVICEID_", deviceId); sw.Write(data); sw.Close(); } var loginResponseB2 = loginRequestB2.GetResponse(); string sLoginCookieB2 = loginResponseB2.Headers[HttpResponseHeader.SetCookie]; string sCookieB2 = loginRequestB2.Headers[HttpRequestHeader.Cookie]; string sLoginLocB2 = loginResponseB2.Headers[HttpResponseHeader.Location]; var loginHeaderB2 = RequestToWeb.ReadHeader(loginResponseB2.Headers); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LẦN 2 HttpWebRequest loginRequest2 = WebRequest.CreateHttp("https://badoo.com/api.phtml?SERVER_LOGIN_BY_PASSWORD"); loginRequest2.CookieContainer = loginCookie; loginRequest2.Method = "POST"; loginRequest2.AllowAutoRedirect = true; loginRequest2.ContentType = "json"; loginRequest2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/64.4.142 Chrome/58.4.3029.142 Safari/537.36"; loginRequest2.KeepAlive = true; //loginRequest2.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br"); loginRequest2.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8,vi;q=0.6"); loginRequest2.Referer = "https://badoo.com/signin"; loginRequest2.Headers.Add("X-Session-id", sLoginCookie.Split(new string[] { "s2=", ";" }, StringSplitOptions.RemoveEmptyEntries)[0]); //loginRequest2.Headers.Add("X-Message-type:15"); using (StreamWriter sw = new StreamWriter(loginRequest2.GetRequestStream())) { string data = File.ReadAllLines("BadooTest.txt")[0]; sw.Write(data); sw.Close(); } var loginResponse2 = loginRequest2.GetResponse(); string sLoginCookie2 = loginResponse2.Headers[HttpResponseHeader.SetCookie]; string sCookie2 = loginRequest2.Headers[HttpRequestHeader.Cookie]; string sLoginLoc2 = loginResponse2.Headers[HttpResponseHeader.Location]; var loginHeader2 = RequestToWeb.ReadHeader(loginResponse2.Headers); string logginS2 = ""; using (StreamReader sr = new StreamReader(loginResponse2.GetResponseStream())) { logginS2 = sr.ReadToEnd(); sr.Close();//Đã ok đến đây } #endregion #region Search #endregion }