Exemple #1
0
        public void DangNhap(ref ThongTinTaiKhoan tk)
        {
            tk.Cookie = new CookieContainer();
            var          response = RequestToWeb.GET(new Uri("https://www.ehenho.com/"), false, true, tk.Cookie);
            var          s        = RequestToWeb.ReadStream(response.GetResponseStream());
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(s);
            var value = document.DocumentNode.SelectSingleNode("//input[@type='hidden' and @name='csrfmiddlewaretoken']").Attributes["value"].Value;

            string data = $"login={tk.TaiKhoan}&password={tk.MatKhau}&remember=on&csrfmiddlewaretoken={value}&remember=on";

            response = RequestToWeb.POST(new Uri("https://www.ehenho.com/accounts/login/"), tk.Cookie, data, true,
                                         config_more: (request) =>
            {
                request.Accept  = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
                request.Referer = "https://www.ehenho.com/";
            });
            if ((response as HttpWebResponse)?.StatusCode == HttpStatusCode.Found)
            {
                tk.TrangThai      = "Đang nhập thành công";
                tk.ChoPhepGuiNhan = true;
            }
            else
            {
                tk.TrangThai = "Đăng nhập thất bại";
                tk.Cookie    = null;
            }
        }
        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");
            }

            var    htmlGet       = RequestToWeb.GET(new Uri("https://www.webtretho.com/forum/private.php?do=newpm"), false, true, nguoigui.Cookie).ReadStream();
            string securitytoken = htmlGet.Substring("SECURITYTOKEN = \"", "\";");

            string data = string.Join("&", new[]
            {
                $"recipients={nguoinhan.TaiKhoan}",
                "bccrecipients=",
                $"title={tieude}",
                $"message_backup={noidung}",
                $"message={noidung}",
                "wysiwyg=0",
                "iconid=0",
                "s=",
                $"securitytoken={securitytoken}",
                "do=insertpm",
                "pmid=",
                "forward=",
                "sbutton=Gửi tin nhắn",
                "savecopy=1 ",
                "parseurl=1",
            });

            var response = RequestToWeb.POST(new Uri("https://www.webtretho.com/forum/private.php?do=insertpm&pmid="), nguoigui.Cookie, data, false, true).ReadStream();
        }
Exemple #3
0
        public void DangNhap(ref ThongTinTaiKhoan tk)
        {
            tk.Cookie = new CookieContainer();
            #region Lấy cookie ban đầu
            var cookieBanDauResponse = RequestToWeb.GET(new Uri("http://cdn.likeyou.vn/sites/all/themes/jam_likeyou/images/bgfacbookren.png"), true, false, tk.Cookie);
            //var cookieBanDauResponse = RequestToWeb.GET(new Uri("http://media.likeyou.vn/"), true, false, tk.Cookie);
            #endregion

            #region Đăng nhập
            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);
            if (dangNhapResponse.ResponseUri != null &&
                dangNhapResponse.ResponseUri.Query != null &&
                dangNhapResponse.ResponseUri.Query.Contains("user="******"Đang nhập thành công";
                tk.ChoPhepGuiNhan = true;
            }
            else
            {
                tk.TrangThai = "Sai tài khoản hoặc mật khẩu";
            }
            #endregion
        }
Exemple #4
0
        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";
            }
        }
Exemple #5
0
        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 void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null)
        {
            if (nguoigui.Cookie == null)
            {
                throw new Exception("Chưa đăng nhập");
            }
            //Gửi tin nhắn
            string guiData = string.Format("idgui={0}&idnhan={1}&tennguoigui={2}&tennguoinhan=AutoSend_{3}&tieude={4}&noidung={5}&btn_submit=GỬI TIN NHẮN",
                                           nguoigui.Id, nguoinhan.Id, nguoigui.TenHienThi, nguoinhan.TenHienThi, tieude, noidung);

            var    guiTinResponse    = RequestToWeb.POST(new Uri("https://henhoketban.vn/guithu.php"), nguoigui.Cookie, guiData, false, true);
            string guiStringResponse = RequestToWeb.ReadStream(guiTinResponse);

            if (guiStringResponse == null)
            {
                nguoigui.ChoPhepGuiNhan = false;
                nguoigui.TrangThai      = "Chuyển tài khoản";
                nguoinhan.TrangThai     = "Gửi lỗi (Web không trả về dữ liệu để xử lý)";
                return;
            }
            if (guiStringResponse.Contains("message.php?guithu=thanhcong"))
            {
                nguoinhan.TrangThai = nguoigui.TaiKhoan;
            }
            else
            {
                nguoinhan.TrangThai = "Gửi lỗi";
            }
        }
Exemple #7
0
        public void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null)
        {
            //Lấy thông tin tài khoản nhận thư
            if (string.IsNullOrEmpty(nguoinhan.Id))
            {
                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 guiThu_data     = string.Format("subject={0}&body={1}&submit=Gởi&ismessage=1", tieude, 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 == null)
            {
                nguoigui.ChoPhepGuiNhan = false;
                nguoigui.TrangThai      = "Chuyển tài khoản";
                nguoinhan.TrangThai     = "Gửi lỗi (Web không trả về dữ liệu để xử lý)";
                return;
            }

            if (guiThu_string == "")
            {
                nguoinhan.TrangThai = nguoigui.TaiKhoan;
            }
            else
            {
                nguoinhan.TrangThai = "Gửi lỗi";
            }
        }
Exemple #8
0
        public void DangNhap(ref ThongTinTaiKhoan tk)
        {
            string data = string.Format("Email={0}&Password={1}&RememberMe=true&returnUrl=%2F", tk.TaiKhoan, tk.MatKhau);

            var response = RequestToWeb.POST(new Uri("https://henho2.com/Account/Login"), null, data, true);
            var httpRes  = response as HttpWebResponse;

            if (httpRes.StatusCode == HttpStatusCode.Found)
            {
                string setCookie = httpRes.Headers[HttpResponseHeader.SetCookie];
                tk.Cookie = new CookieContainer();
                tk.Cookie.SetCookies(UriTrangWeb.HenHo2, setCookie);
                tk.TrangThai = "Đang nhập thành công";
            }
            else
            {
                tk.TrangThai = "Sai tài khoản hoặc mật khẩu";
                tk.Cookie    = null;
            }

            httpRes.Close();
            httpRes.Dispose();

            response.Close();
            response.Dispose();
        }
Exemple #9
0
        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";
            }
        }
Exemple #10
0
        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 data = string.Format("IdTo={0}&NameTo={1}&Title={2}&MessageContent={3}", nguoinhan.Id, nguoinhan.TenHienThi, tieude, noidung);

            var response = RequestToWeb.POST(new Uri("https://henho2.com/Message/Create"), nguoigui.Cookie, data, false, true);

            nguoinhan.TrangThai = nguoigui.TaiKhoan;
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                string stringResponse = sr.ReadToEnd();
                if (stringResponse == null)
                {
                    nguoigui.TrangThai      = "Chuyển tài khoản";
                    nguoigui.ChoPhepGuiNhan = false;
                    nguoinhan.TrangThai     = "Gửi lỗi (Web không trả về dữ liệu để xử lý)";
                }
                if (stringResponse != null && !stringResponse.Contains("Gửi tin nhắn th&#224;nh c&#244;ng"))
                {
                    if (stringResponse.Contains("gửi qu&#225; số thư cho ph&#233;p"))
                    {
                        nguoinhan.TrangThai     = "Gửi lỗi\n(quá số thư cho phép)";
                        nguoigui.TrangThai      = "Quá số thư cho phép";
                        nguoigui.ChoPhepGuiNhan = false;
                    }
                    else if (stringResponse.Contains("Vui l&#242;ng nhập từ"))
                    {
                        nguoinhan.TrangThai = "Gửi lỗi\n(quá ngắn)";
                    }
                    else if (stringResponse.Contains("Chưa kích hoạt"))
                    {
                        nguoigui.TrangThai      = nguoinhan.TrangThai = "Chưa kích hoạt";
                        nguoigui.ChoPhepGuiNhan = false;
                    }
                    else if (stringResponse.Contains("Bạn đ&#227; bị ban"))
                    {
                        nguoigui.TrangThai = nguoinhan.TrangThai = "Gửi lỗi\n(tài khoản bị khóa)";
                        if (callback != null)
                        {
                            callback(CONST_HENHO2.TAI_KHOAN_BI_KHOA);
                        }
                        nguoigui.ChoPhepGuiNhan = false;
                    }
                    else
                    {
                        nguoigui.TrangThai      = nguoinhan.TrangThai = "Gửi lỗi\n(nhập lại tài khoản)";
                        nguoigui.ChoPhepGuiNhan = false;
                    }
                }
            }
        }
        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 GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null)
        {
            if (nguoigui.Cookie == null)
            {
                throw new Exception("Thiếu cookie");
            }

            string data = string.Format("cmd=send_message&user_to={0}&msg={1}&to_delete=0", nguoinhan.Id, noidung);

            var response = RequestToWeb.POST(new Uri("http://duyenso.com/ajax.php"), nguoigui.Cookie, data, false);

            if (response == null)
            {
                nguoinhan.TrangThai = "Gửi lỗi (Time out)";
                return;
            }

            nguoinhan.TrangThai = nguoigui.TaiKhoan;
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                string stringResponse = sr.ReadToEnd();
                if (stringResponse == null)
                {
                    nguoigui.ChoPhepGuiNhan = false;
                    nguoigui.TrangThai      = "Chuyển tài khoản";
                    nguoinhan.TrangThai     = "Gửi lỗi (Web không trả về dữ liệu để xử lý)";
                    return;
                }
                if (stringResponse != null && !stringResponse.Contains("ERROR") && !stringResponse.Contains("Error"))
                {
                    if (stringResponse.Contains("VIP"))
                    {
                        nguoinhan.TrangThai = "Thất bại (Cần VIP)";
                    }
                }
                else
                {
                    nguoinhan.TrangThai = "Gửi lỗi (Server)";
                }

                if (stringResponse != null)
                {
                    var    dataResponse = stringResponse.Split('"');
                    string senderId     = dataResponse[6].Trim();

                    string dataUpdate = string.Format("cmd=pp_messages&user_id={0}&is_mode_fb=false", nguoinhan.Id);

                    var resUpdate = RequestToWeb.POST(new Uri("http://duyenso.com/ajax.php"), nguoigui.Cookie, dataUpdate, true);
                }
            }
        }
Exemple #13
0
        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";
            }
        }
Exemple #14
0
        public void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null)
        {
            HttpWebResponse response = RequestToWeb.GET(new Uri(nguoinhan.Url), false, true, nguoigui.Cookie) as HttpWebResponse;
            string          htmlText = RequestToWeb.ReadStream(response.GetResponseStream());

            if (htmlText.Contains("class=\"msg-cp\""))
            {
                HtmlDocument document = new HtmlDocument();
                document.LoadHtml(htmlText);
                var    csrfmiddlewaretoken = document.DocumentNode.SelectSingleNode("//input[@type='hidden' and @name='csrfmiddlewaretoken']").Attributes["value"].Value;
                string data         = $"csrfmiddlewaretoken={csrfmiddlewaretoken}&body={noidung}&send=      Gửi!      ";
                string responseHtml = RequestToWeb.ReadStream(RequestToWeb.POST(new Uri(nguoinhan.Url), nguoigui.Cookie, data, false, true,
                                                                                config_more: (request) =>
                {
                    request.Accept  = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
                    request.Referer = nguoinhan.Url;
                }));

                if (responseHtml == null)
                {
                    nguoinhan.TrangThai     = nguoigui.TrangThai = "Gửi lỗi\r\nKhông đọc được nội dung";
                    nguoigui.ChoPhepGuiNhan = false;
                    nguoinhan.TrangThai     = "Gửi lỗi (Web không trả về dữ liệu để xử lý)";
                }
                else if (responseHtml?.Contains("Thư gửi không thành công!") ?? true)
                {
                    nguoinhan.TrangThai     = nguoigui.TrangThai = "Gửi lỗi\nQuá giới hạn 48 thư";
                    nguoigui.ChoPhepGuiNhan = false;
                }
                else
                {
                    nguoinhan.TrangThai = nguoigui.TaiKhoan;
                }
            }
            else
            {
                nguoinhan.TrangThai     = nguoigui.TrangThai = "Gửi lỗi. Tài khoản bị khóa";
                nguoigui.ChoPhepGuiNhan = false;
            }
        }
        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 async Task <ThongTinTaiKhoan> DangKyTaiKhoanMoiAsync(string tai_khoan, string mat_khau, string ho_ten, Func <string> captcha, ThongTinBoSung thong_tin_bo_sung = null)
        {
            try
            {
                CookieContainer _cookieContainer = new CookieContainer();

                string          linkDangKy = "https://ehenho.com/accounts/signup/";
                HttpWebResponse response   = await RequestToWeb.GETAsync(new Uri(linkDangKy), false, true, _cookieContainer) as HttpWebResponse;

                //var cookies = _cookieContainer.GetAllCookies();
                var check = await RequestToWeb.GETAsync(new Uri("https://ehenho.com/static/js/provinces/tp-ho-chi-minh.js"), true, cookie : _cookieContainer);

                string       csrfTokenHeader = _cookieContainer.GetCookie("csrftoken");
                HtmlDocument document        = new HtmlDocument();
                string       htmlText        = HttpUtility.HtmlDecode(RequestToWeb.ReadStream(response.GetResponseStream()));
                document.LoadHtml(htmlText);
                string csrfmiddlewaretoken = document.DocumentNode.SelectSingleNode("//input[@type='hidden' and @name='csrfmiddlewaretoken']").Attributes["value"].Value;

                Random        rand             = new Random();
                List <string> tinhTrangHonNhan = new List <string>()
                {
                    "single", "divorced", "widowed", "in-relationship"
                };
                List <string> mucTieu = new List <string>()
                {
                    "long-term-love", "short-term-love", "new-friends", "chat-or-intimate-friends", "marriage", "life-mate"
                };
                List <string> hocVan = new List <string>()
                {
                    "GRA", "VCA", "ASO", "BAC", "MAS", "AMA"
                };
                List <string> noiO = new List <string>()
                {
                    "tp-ho-chi-minh", "ha-noi", "an-giang", "ba-ria-vung-tau", "bac-lieu", "ca-mau", "gia-lai", "son-la", "lang-son", "ninh-binh", "da-nang", "dien-bien", "tuyen-quang"
                };
                List <string> headline = new List <string>()
                {
                    "Em mộc mạc", "Tìm anh à", "Bố mẹ dục cưới", "Bị bắt cưới", "Làm đám cưới", "Tìm người giàu", "Nhà điều kiện"
                };
                List <string> profiles = new List <string>()
                {
                    "Muốn hẹn hò kết bạn", "TÌm người yêu", "Cần một muối quan hệ lâu dài", "Đã có con, nếu không ngại thì inbox làm quen", "Đang bị dục cưới", "Bố mẹ bắt cưới, cần tìm bạn tình gấp", "Chả có gì giới thiệu cả"
                };

                string data = $"csrfmiddlewaretoken={csrfmiddlewaretoken}&email={tai_khoan}&password={mat_khau}&name={ho_ten}" +
                              $"&dob_day={rand.Next(1, 28)}&dob_month={rand.Next(1, 12)}&dob_year={rand.Next(1986, 2005)}&gender={thong_tin_bo_sung.GioiTinh}" +
                              $"&marital_status={tinhTrangHonNhan.GetRandomElement()}&look_for={mucTieu.GetRandomElement()}&height={rand.Next(145, 208)}" +
                              $"&weight={rand.Next(35, 80)}&education={hocVan.GetRandomElement()}&province={noiO.GetRandomElement()}&headline={headline.GetRandomElement()}" +
                              $"&master_appearance={rand.Next(1, 50)}&master_interest={rand.Next(1, 417)}&master_personality={rand.Next(1, 496)}" +
                              $"&way_of_life={rand.Next(1, 64)}&most_valued={rand.Next(1, 53)}&i_am={profiles.GetRandomElement()}&my_match={profiles.GetRandomElement()}" +
                              $"&setfc_flag=on&appearance_str1=2&appearance_str2=&appearance_str3=&interest_str1=3&interest_str2=" +
                              $"&interest_str3=&interest_str4=&interest_str5=&personality_str1=2&personality_str2=&personality_str3=&personality_str4=" +
                              $"&personality_str5=&personality_str6=&personality_str7=&way_of_life_str=7&most_valued_str=3&submit=Đăng ký";

                response = RequestToWeb.POST(new Uri(linkDangKy), _cookieContainer, data, false, true,
                                             config_more: (req) =>
                {
                    req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
                    req.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
                    req.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.9,vi;q=0.8");
                    req.Headers.Add(HttpRequestHeader.CacheControl, "max-age=0");
                    //req.KeepAlive = true;
                    //req.Connection = "keep-alive";

                    req.Headers.Add("DNT", "1");

                    //req.Host = "ehenho.com";
                    req.Headers.Add("Origin", "https://ehenho.com");
                    req.Referer = "https://ehenho.com/accounts/signup/";

                    req.Headers.Add("Sec-Fetch-Mode", "navigate");
                    req.Headers.Add("Sec-Fetch-Site", "same-origin");
                    //req.Headers.Add("Sec-Fetch-User", "?1");
                    //req.Headers.Add("Upgrade-Insecure-Requests", "1");

                    req.Headers.Add("X-CSRFToken", csrfTokenHeader);
                }) as HttpWebResponse;


                if (response == null)
                {
                    return new ThongTinTaiKhoan()
                           {
                               TaiKhoan = null, TrangThai = "Lỗi: Web phản hồi quá lâu"
                           }
                }
                ;

                var res = HttpUtility.HtmlDecode(RequestToWeb.ReadStream(response.GetResponseStream()));
                if (response.StatusCode == HttpStatusCode.Found)
                {
                    return new ThongTinTaiKhoan()
                           {
                               TaiKhoan = tai_khoan, MatKhau = mat_khau
                           }
                }
                ;
                else
                {
                    return new ThongTinTaiKhoan()
                           {
                               TaiKhoan = null, TrangThai = "Tạo lỗi"
                           }
                };
            }
            catch (Exception ex)
            {
                return(new ThongTinTaiKhoan()
                {
                    TaiKhoan = null, TrangThai = "Lỗi chưa xác định"
                });
            }
        }
Exemple #17
0
        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++;
                }
            }
        }
Exemple #18
0
        public void DangNhap(ref ThongTinTaiKhoan tk)
        {
            #region Logout
            ////Https nên có xác thực => nếu không đăng xuất sẽ bị lấy phiên đăng nhập cũ
            //HttpWebRequest logoutRequest = WebRequest.CreateHttp("https://www.vietnamcupid.com/vi/auth/logout");
            //logoutRequest.Method = "GET";
            //var logoutResponse = RequestToWeb.GET(new Uri("https://www.vietnamcupid.com/vi/auth/logout"), true);
            #endregion

            #region Login
            tk.Cookie = new CookieContainer();

            #region Login 1: Get first Cookie, Parameter
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
            client.DefaultRequestHeaders.Add("Accept-Language", "vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5");
            client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br");

            client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/78.0.136 Chrome/72.0.3626.136 Safari/537.36");
            var x = client.GetAsync("https://www.vietnamcupid.com/en/auth/login").Result.ReadStringAsync().Result;

            var loginResponse = RequestToWeb.GET(new Uri("https://www.vietnamcupid.com/en/auth/login"), false, true, tk.Cookie,
                                                 (req) =>
            {
                //req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
                req.Headers.Add(HttpRequestHeader.AcceptLanguage, "vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5");
                req.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
            });
            var loginPageHtml = RequestToWeb.ReadStream(loginResponse);
            HtmlAgilityPack.HtmlDocument docLogin = new HtmlAgilityPack.HtmlDocument();
            docLogin.LoadHtml(loginPageHtml);
            var formLogin = docLogin.DocumentNode.QuerySelector("form > input");
            #endregion Login 1: Get first Cookie

            #region Login 2: Get login cookie
            string ioBB = docLogin.GetElementbyId("ioBB").GetAttributeValue("value", "");
            string mht  = docLogin.DocumentNode.SelectSingleNode("//input[@type='hidden' and @name='mht']").Attributes["value"].Value;

            string loginData      = $"mht={mht}&page=&email={tk.TaiKhoan}&password={tk.MatKhau}&RememberMe=on&ioBB={ioBB}";
            var    loginResponse2 = RequestToWeb.POST(new Uri("https://www.vietnamcupid.com/logon_do.cfm"), tk.Cookie, loginData, true);// loginRequest2.GetResponse();

            string sLoginCookie2 = loginResponse2.Headers[HttpResponseHeader.SetCookie];
            string sLoginLoc2    = loginResponse2.Headers[HttpResponseHeader.Location];
            tk.TrangThai      = "Đang nhập thành công";
            tk.ChoPhepGuiNhan = true;
            if (sLoginLoc2.Contains("error"))
            {
                tk.TrangThai      = "Sai tài khoản hoặc mật khẩu";
                tk.Cookie         = null;
                tk.ChoPhepGuiNhan = false;
            }
            //Https chưa lưu được cookie
            //else
            //{
            //    foreach (Cookie cook in tk.Cookie.GetCookies(UriTrangWeb.VietNamCupid))
            //    {
            //        if (cook.Name == "_DIST")
            //        {
            //            tk.HanCookie = cook.Expires;
            //        }
            //    }
            //}

            #endregion Login 2: Get login cookie

            #endregion
        }
Exemple #19
0
        public IEnumerable <ThongTinTaiKhoan> TimKiem(ThongTinTimKiem param)
        {
            int pageindex = 1;

            while (true)
            {
                #region Tạo reqeuest
                var         uri = new UriBuilder("https://www.vietnamcupid.com/");
                WebResponse response;
                if (pageindex == 1)
                {
                    uri = new UriBuilder("https://www.vietnamcupid.com/vi/results/search?searchtype=1");
                    string data = string.Format("resulttype=advanced&gender_w={0}&age_min={1}&age_max={2}", param.GioiTinh, param.TuTuoi, param.DenTuoi);
                    data += string.Format("&countryLive=230&stateLive={0}", param.NoiO);
                    foreach (var hn in param.HonNhan)
                    {
                        data += string.Format("&maritalStatus={0}", hn.Id);
                    }
                    data    += "&cityLive=-1&searchingFor=-1&resetCurrency=VND&distanceUnit=kms&gender=254";
                    response = RequestToWeb.POST(uri.Uri, this.Cookie, data, false, true);
                }
                else
                {
                    uri      = new UriBuilder(string.Format("https://www.vietnamcupid.com/vi/results/search?pageno={0}", pageindex));
                    response = RequestToWeb.GET(uri.Uri, false, false, this.Cookie);
                }
                #endregion

                #region Lấy dữ liệu
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    string content = sr.ReadToEnd();
                    //string content = File.ReadAllText("DataHtmlTest.txt");
                    content = HttpUtility.HtmlDecode(content);

                    HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
                    document.LoadHtml(content);

                    var bangKetQua = document.DocumentNode.QuerySelectorAll("div#memberships > div").ToList();
                    for (int i = 0; i < bangKetQua.Count; i++)
                    {
                        ThongTinTaiKhoan taiKhoan = new ThongTinTaiKhoan();
                        var memberpicgeneric      = bangKetQua[i].QuerySelectorAll("div > div > p");
                        if (memberpicgeneric.Count() < 2)
                        {
                            continue;//Quảng cáo
                        }
                        var hdg1 = memberpicgeneric.ElementAt(0).QuerySelector("a");
                        var hdg2 = memberpicgeneric.ElementAt(1);
                        if (memberpicgeneric != null)
                        {
                            string duongDan = hdg1.GetAttributeValue("href", "");
                            if (!string.IsNullOrEmpty(duongDan))
                            {
                                try
                                {
                                    var    tmpUri  = new Uri("https://www.vietnamcupid.com" + duongDan);
                                    string id      = tmpUri.Segments[tmpUri.Segments.Count() - 1];
                                    var    tenTuoi = hdg1.InnerHtml.Split('(', ')').Where(p => !string.IsNullOrEmpty(p)).ToList();
                                    string ten     = tenTuoi[0];
                                    string tuoi    = tenTuoi[tenTuoi.Count - 1];//lấy tuổi cuối cùng

                                    string noiO = "";
                                    if (hdg2.ChildNodes.Count >= 1)
                                    {
                                        noiO = hdg2.ChildNodes[1].InnerText.TrimAll();
                                    }
                                    else
                                    {
                                        try
                                        {
                                            var tmp = bangKetQua[i].QuerySelectorAll("div > div").FirstOrDefault();
                                            noiO = tmp.ChildNodes[2].InnerText.TrimAll();
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    taiKhoan.Url              = string.Format("https://www.vietnamcupid.com/vi/profile/showProfile/ID/{0}", id);
                                    taiKhoan.Id               = id;
                                    taiKhoan.TenHienThi       = ten.Trim();
                                    taiKhoan.ChoPhepGuiNhan   = true;
                                    taiKhoan.Tuoi             = tuoi.ConvertToInt32();
                                    taiKhoan.GioiTinh         = param.OtherParam[0].ToString();
                                    taiKhoan.NoiO             = noiO;
                                    taiKhoan.TinhTrangHonNhan = param.OtherParam[1].ToString();
                                }
                                catch//(Exception ex)
                                { taiKhoan = null; }

                                if (taiKhoan != null)
                                {
                                    yield return(taiKhoan);
                                }

                                if (param.DungTimKiem)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    //Test: break;
                    if (bangKetQua.Count <= 1)
                    {
                        break;
                    }
                }
                #endregion

                if (param.DungTimKiem)
                {
                    break;
                }

                pageindex++;
            }
        }