public int obtainLoginPage() { form1.setLogT(Client.FamilyName + " " + Client.GivenName + " " + Client.PassportNo + ": obtainLoginPage.."); string respHtml = ""; /* * respHtml = Form1.weLoveYue( * form1, * "https://www.immigration.govt.nz/secure/Login+Working+Holiday.htm", * "GET", * "", * true, * "", * ref cookieContainer, * true); * // cookieContainer.Add(new Cookie("TS0120d49b", "0152807fb20d92231761cb749be9bf0c068e6b51b7b7c8b3ca3163b50d0ded4393ddab932f0e53bfd0276edcf78ed51aeba4f9a69be4cf15ca8c961e1184690d83fa9fded1") { Domain = "www.immigration.govt.nz" }); * // cookieContainer.Add(new Cookie("ASP.NET_SessionId", "vr5pmzbicspjp455xatxmcmk") { Domain = "www.immigration.govt.nz" }); * * // cookieContainer.Add(new Cookie("BIGipServerwww.immigration.govt.nz", "342776330.20480.0000") { Domain = "www.immigration.govt.nz" }); */ HttpWebResponse resp = null; Client.cookieContainer = null; obtainLoginPage: if (true) //(Client.cookieContainer == null || Client.cookieContainer.Count == 0) { resp = Form1.weLoveYueer( form1, "https://onlineservices.immigration.govt.nz/?WHS", "GET", "", false, "", ref Client.cookieContainer ); respHtml = Form1.resp2html(resp); if (Client.cookieContainer == null) { Client.cookieContainer = new CookieCollection(); } Cookie initCookie = new Cookie(); initCookie.Domain = "onlineservices.immigration.govt.nz"; initCookie.Expired = false; initCookie.Expires = DateTime.Now.AddMinutes(2); initCookie.Path = "/"; initCookie.Name = "TSaa03129d_75"; initCookie.Value = "TSaa03129d_rc=1&TSaa03129d_id=5&TSaa03129d_cr=08819c2a25ab2800eacd11de26753b563f9e6ff0e7b4ed741557ff284836adf9e2c5a59581edf8a45c5d692d08327d7a:089ca66b58047800584e1fa83189d1046e7903fa98539f813fd72464691dd253e4cfbeae90da59b31ae15e5aeeb1e7472366cfad29d6730c072302631b30f7cff1e7fa9cf2c03b44ac30e2a91a88c262d696615637e3b5d35699c5f460762b21a3078f077eb532c3a6367c27e3f5d3ca9dc12779359cf385e03f6f449281d111&TSaa03129d_ef=&TSaa03129d_pg=0&TSaa03129d_ct=0&TSaa03129d_rf=0"; Client.cookieContainer.Add(initCookie); initCookie = new Cookie(); initCookie.Domain = "onlineservices.immigration.govt.nz"; initCookie.Expired = false; initCookie.Expires = DateTime.Now.AddYears(2); initCookie.Path = "/"; initCookie.Name = "TSPD_101"; initCookie.Value = "08819c2a25ab2800eacd11de26753b563f9e6ff0e7b4ed741557ff284836adf9e2c5a59581edf8a45c5d692d08327d7a:"; Client.cookieContainer.Add(initCookie); resp = Form1.weLoveYueer( form1, "https://onlineservices.immigration.govt.nz/?WHS", "GET", "", false, //"&TS0120d49b_cr=08eba48ebbab28003238e681cda9bcdb55fb8668c04df479fb10d8abfc03767f1e29dd" //+ "c98c63655c45544f7c3017e8a208a31e8d5e894800b1f1ba4a307fa5e66367f309e83050399eeb03126a5ccd8d6d47cb838f19f033c01b6797071278b6a0f3675c971bb86c9a33cf630623fb90ced6a4a3b20b3e59b1ed1519a48b7fff" //+ //"TS0120d49b_id=3&TS0120d49b_76=0&TS0120d49b_86=0&TS0120d49b_md=1&TS0120d49b_rf=0&TS0120d49b_ct=0&TS0120d49b_pd=0", //"TS8e49d4_id=3&TS8e49d4_md=1&TS8e49d4_rf=0&TS8e49d4_ct=0&TS8e49d4_pd=0", //this code comes from yuejie@20160320 "", ref Client.cookieContainer ); } else { resp = Form1.weLoveYueer( form1, "https://onlineservices.immigration.govt.nz/secure/Login+Working+Holiday.htm", "GET", "https://onlineservices.immigration.govt.nz/secure/Login+Working+Holiday.htm", false, "", ref Client.cookieContainer ); } if (resp == null) { goto obtainLoginPage; } if (resp.StatusCode == HttpStatusCode.Found) { form1.setLogT("getting login page failed!"); return(-1); } respHtml = Form1.resp2html(resp); if (Form1.debug) { form1.setTestLog(respHtml); } return(-9999999);//dyyr rgx = @"(?<=name=""__VIEWSTATE"" value="")(\s|\S)+?(?="")"; myMatch = (new Regex(rgx)).Match(respHtml); if (myMatch.Success) { Client.__VIEWSTATE = Form1.ToUrlEncode(myMatch.Groups[0].Value); } else { form1.setLogT("getting login page failed!"); return(-1); } rgx = @"(?<=var __CMS_CurrentUrl = "")(\s|\S)+?(?="")"; myMatch = (new Regex(rgx)).Match(respHtml); if (myMatch.Success) { Client.__CMS_CurrentUrl = myMatch.Groups[0].Value; } else { form1.setLogT("getting login page failed!"); return(-1); } rgx = @"(?<=name=""__VIEWSTATEGENERATOR"" value="")(\s|\S)+?(?="")"; myMatch = (new Regex(rgx)).Match(respHtml); if (myMatch.Success) { Client.__VIEWSTATEGENERATOR = myMatch.Groups[0].Value; } else { form1.setLogT("getting login page failed!"); return(-1); } // cookieContainer.Add(new Cookie("_js_datr", datr) { Domain = "www.facebook.com" }); //to get cookies: datr // weLoveMuYue("https://www.facebook.com/hellocdn/results?data=%7B%22results%22%3A%5B%7B%22loading_time%22%3A0%2C%22platform%22%3A%22www%22%2C%22cdn%22%3A%22ak%22%2C%22resource_timing%22%3A%7B%22name%22%3A%22https%3A%2F%2Ffbcdn-photos-b-a.akamaihd.net%2Fhphotos-ak-prn1%2Ftest-80KB.jpg%22%2C%22entryType%22%3A%22resource%22%2C%22startTime%22%3A307.131182%2C%22duration%22%3A422.90310700000003%2C%22initiatorType%22%3A%22xmlhttprequest%22%2C%22redirectStart%22%3A0%2C%22redirectEnd%22%3A0%2C%22fetchStart%22%3A307.131182%2C%22domainLookupStart%22%3A307.131182%2C%22domainLookupEnd%22%3A307.131182%2C%22connectStart%22%3A307.131182%2C%22connectEnd%22%3A307.131182%2C%22secureConnectionStart%22%3A0%2C%22requestStart%22%3A308.652099%2C%22responseStart%22%3A398.19683299999997%2C%22responseEnd%22%3A730.0342890000001%7D%2C%22url%22%3A%22https%3A%2F%2Ffbcdn-photos-b-a.akamaihd.net%2Fhphotos-ak-prn1%2Ftest-80KB.jpg%22%2C%22headers%22%3A%22Access-Control-Allow-Origin%3A%20*%5Cr%5CnCache-Control%3A%20no-transform%2C%20max-age%3D8%5Cr%5CnContent-Length%3A%2079957%5Cr%5CnContent-Type%3A%20image%2Fjpeg%5Cr%5CnDate%3A%20Sat%2C%2019%20Sep%202015%2003%3A55%3A59%20GMT%5Cr%5CnExpires%3A%20Sat%2C%2019%20Sep%202015%2003%3A56%3A07%20GMT%5Cr%5CnLast-Modified%3A%20Fri%2C%2012%20Dec%202014%2000%3A53%3A28%20GMT%5Cr%5CnServer%3A%20proxygen%5Cr%5CnTiming-Allow-Origin%3A%20*%5Cr%5Cnx-akamai-session-info%3A%20name%3DBEGIN_CLOCK%3B%20value%3D1435761000%2C%20name%3DCLOCK_DURATION%3B%20value%3D6873959%2C%20name%3DFB_DISABLE_FULL_HTTPS%3B%20value%3Dtrue%2C%20name%3DFB_DISABLE_FULL_LOGGING%3B%20value%3Dtrue%2C%20name%3DFB_LOGGING_URL_SAMPLE%3B%20value%3Dtrue%2C%20name%3DFULL_PATH_KEY%3B%20value%3Dfalse%2C%20name%3DHSAFSERIAL%3B%20value%3D842%2C%20name%3DNOW_CLOCK%3B%20value%3D1442634959%2C%20name%3DORIGIN%3B%20value%3Dhphotos-ak-prn1%2C%20name%3DOVERRIDE_HTTPS_IE_CACHE_BUST%3B%20value%3Dall%2C%20name%3DSERIALNEXT%3B%20value%3D1791%2C%20name%3DSINGLE_TIER%3B%20value%3Dtrue%2C%20name%3DSINGLE_TIER_HVAL%3B%20value%3D789613%2C%20name%3DVALIDORIGIN%3B%20value%3Dtrue%3B%20full_location_id%3Dmetadata%5Cr%5Cnx-akamai-ssl-client-sid%3A%20B2VGSAuDC%2BONy6lq7deAkQ%3D%3D%2C%20jXyFJAJ1swG8eI9JJLO85A%3D%3D%2C%20eHGuYL6ebCGxtQ%2FFzTWoqQ%3D%3D%2C%20xTmDZCNM%2BaM1EFSiyU%2B5PQ%3D%3D%2C%2000ViDZZBGURh2d4RBXYqtA%3D%3D%2C%20ldw%2F1r4y03Q8umDIRzyoDw%3D%3D%2C%20QoOhGh3xuf88M%2BjTOOnWfg%3D%3D%2C%20Z8kyY5MKFQLQt3zz2YkPsQ%3D%3D%2C%20slblWhmVC8ViR3qetpM4dw%3D%3D%2C%20xrYGqTI4Hs1DdfyZ5Yx27w%3D%3D%2C%20VjZkcoaZbgPN8byHaDILuA%3D%3D%2C%20p4Jq2SVzcMwCfYiMGWuigg%3D%3D%2C%20rMFYfXpdb3PLXvjNNOBgrw%3D%3D%5Cr%5CnX-Cache%3A%20TCP_MISS%20from%20a119-224-129-198.deploy.akamaitechnologies.com%20(AkamaiGHost%2F7.3.2.2-15906379)%20(-)%5Cr%5Cnx-cache-key%3A%20S%2FL%2F1791%2F98030%2F14d%2Fphoto.facebook.com%2Ftest-80KB.jpg%5Cr%5Cnx-cache-remote%3A%20TCP_HIT%20from%20a119-224-129-207.deploy.akamaitechnologies.com%20(AkamaiGHost%2F7.3.2.2-15906379)%20(-)%5Cr%5Cnx-check-cacheable%3A%20YES%5Cr%5Cnx-serial%3A%201791%5Cr%5Cnx-true-cache-key%3A%20%2FL%2Fphoto.facebook.com%2Ftest-80KB.jpg%5Cr%5CnX-Firefox-Spdy%3A%203.1%5Cr%5Cn%22%2C%22status%22%3A200%7D%5D%7D", // "GET", // "", // false, // ""); Client.nextStep = "login"; login(); return(1); }
public int login() { form1.setLogT(Client.FamilyName + " " + Client.GivenName + " " + Client.PassportNo + ": login.."); HttpWebResponse resp = null; login: resp = Form1.weLoveYueer( form1, "https://onlineservices.immigration.govt.nz" + Client.__CMS_CurrentUrl, "POST", "https://onlineservices.immigration.govt.nz/secure/Login+Working+Holiday.htm", false, "__EVENTTARGET=" + "&__EVENTARGUMENT=" + "&__VIEWSTATEGENERATOR=" + Client.__VIEWSTATEGENERATOR + "&HeaderCommunityHomepage%3ASearchControl%3AtxtSearchString=" + "&VisaDropDown=%2Fsecure%2FLogin%2BWorking%2BHoliday.htm" + "&OnlineServicesLoginStealth%3AVisaLoginControl%3AuserNameTextBox=" + Form1.ToUrlEncode(Client.UserName) + "&OnlineServicesLoginStealth%3AVisaLoginControl%3ApasswordTextBox=" + Form1.ToUrlEncode(Client.Password) + "&OnlineServicesLoginStealth%3AVisaLoginControl%3AloginImageButton.x=42" + "&OnlineServicesLoginStealth%3AVisaLoginControl%3AloginImageButton.y=10" + "&__VIEWSTATE=" + Client.__VIEWSTATE, ref Client.cookieContainer ); if (resp == null) { goto login; } if (resp.StatusCode == HttpStatusCode.Found) { form1.setLogtRed("login succeed"); Form1.gLoginOkFlag = true; Client.nextStep = "createNewFormPage"; return(1); } string respHtml = Form1.resp2html(resp); if (respHtml.Contains("Incorrect email or phone number") || respHtml.Contains("It looks like you entered a slight misspelling of your email or username") || respHtml.Contains("The email you entered does not belong to any account") ) { form1.setLogT(Client.FamilyName + " " + Client.GivenName + " " + Client.PassportNo + ": username error!"); return(-1); } else if (respHtml.Contains("The password you entered is incorrect") || respHtml.Contains("You have entered an incorrect user name or password")) { form1.setLogT(Client.FamilyName + " " + Client.GivenName + " " + Client.PassportNo + ": password error!"); return(-1); } else if (respHtml.Contains("Please enable cookies in your browser preferences to continue")) { form1.setLogT(Client.FamilyName + " " + Client.GivenName + " " + Client.PassportNo + ": cookies error!"); return(-1); } return(-2); }
public void startProbe() { if (form1.mailGrid.InvokeRequired) { delegate2 sl = new delegate2(delegate() { form1.deleteMail.Enabled = false; form1.deleteApp.Enabled = false; }); form1.mailGrid.Invoke(sl); } else { form1.deleteMail.Enabled = false; form1.deleteApp.Enabled = false; } form1.setLogT("probe started. CardNo:" + appointment.CardNo + ", " + form1.selecteCounty.Name + " " + form1.selecteCounty.Shops[form1.selectedShop]); while (true) { if (Form1.gForceToStop) { break; } int r1 = 0; //新潟亀田アピタ店 M // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90V%8a%83%8c%a7&event_type=6&sid=37140&kmws= //アリオ上田店 M // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37194&kmws= //songben M // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37196&kmws= //ららぽーと横浜店 // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90_%93%de%90%ec%8c%a7&event_type=6&sid=37139&kmws= //春日井店 //http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%88%a4%92m%8c%a7&event_type=6&sid=37038&kmws= while ((r1 = this.probe( Form1.ToUrlEncode( form1.selecteCounty.Shops[form1.selectedShop], System.Text.Encoding.GetEncoding("shift-jis") ), form1.selecteCounty.Sids[form1.selectedShop]) ) == -1) //"%88%a4%92m%8c%a7", "37038" { } if (r1 == -5) //no available appointment { goto delay; } delay: //不写在while的开头,避免第一次就延时 if (form1.rate.Text.Equals("")) { Thread.Sleep(100); } else { try{ if (Convert.ToInt32(form1.rate.Text) > 0) { Thread.Sleep(Convert.ToInt32(form1.rate.Text)); } else { Thread.Sleep(100); } } catch (Exception) { Thread.Sleep(100); } } }//end of while if (form1.mailGrid.InvokeRequired) { delegate2 sl = new delegate2(delegate() { form1.deleteMail.Enabled = true; }); form1.mailGrid.Invoke(sl); } else { form1.deleteMail.Enabled = true; } Form1.gForceToStop = false; return; }
public void showNextAppTime() { string county = form1.selecteCounty.Shops[form1.selectedShop]; //big surprise!!! the official entrance is the encoding with s-jis of county's name, BUT, shop's name also works! And now I use shop's name with others' will narely do string shop = form1.selecteCounty.Sids[form1.selectedShop]; string forTest = Form1.ToUrlEncode( county, System.Text.Encoding.GetEncoding("shift-jis") ); DateTime dateTime = DateTime.MinValue; string day = ""; string time = ""; string html = Form1.weLoveYue( form1, "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + Form1.ToUrlEncode( county, System.Text.Encoding.GetEncoding("shift-jis") ) + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=", "GET", "", false, "", ref cookieContainer, false ); //available // <th>予約受付期間</th> // <td> // 10/12<font color="#ff0000">(月)</font> 13:30~10/12<font color="#ff0000">(月)</font> 22:00<br /> if (county == form1.selecteCounty.Shops[form1.selectedShop] && shop == form1.selecteCounty.Sids[form1.selectedShop] && sizeType == form1.selectedType) { rgx = @"(?<=<th>予約受付期間</th>\n.*\n\s*)\d+\/\d+(?=\D)"; myMatch = (new Regex(rgx)).Match(html); while (myMatch.Success) { day = myMatch.Groups[0].Value;// no available appointment rgx = @"(?<=<th>予約受付期間</th>\n.*\n\s*" + day + @"(\s|\S)+?)\d+\:\d+(?=\D)"; Match match2 = (new Regex(rgx)).Match(html); if (match2.Success) { time = match2.Groups[0].Value; DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy-M-d hh:mm:ss"; dateTime = Convert.ToDateTime("2015-" + Regex.Match(day, @"\d+(?=\/)") + "-" + Regex.Match(day, @"(?<=\/)\d+") + " " + time + ":00"); //how to find the year ? TimeZoneInfo jst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"); TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"); DateTime nowInTokyoTime = TimeZoneInfo.ConvertTime(DateTime.Now, jst); if ((dateTime - nowInTokyoTime).TotalMinutes > -15) { delegate2 d111 = new delegate2( delegate() { form1.label14.Text = "the nearest booking on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county + " is on: \n" + dateTime.ToString("MM/dd HH:mm") + " Tokyo Standard Time\n" + TimeZoneInfo.ConvertTimeFromUtc(TimeZoneInfo.ConvertTimeToUtc(dateTime, jst), cst).ToString("MM/dd HH:mm") + " China Standard Time" ; } ); form1.label14.Invoke(d111); return; } } myMatch = myMatch.NextMatch(); } delegate2 d222 = new delegate2( delegate() { if (Regex.Match(html, @"条件に一致する予約販売が存在しません").Success) { form1.label14.Text = "There is no type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county; } else { form1.label14.Text = "No available booking these days on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county; } } ); form1.label14.Invoke(d222); }//end of if the search option not changed }
public int setAppointment(string email, string url) { form1.setLogT("CardNo" + appointment.CardNo + ", start setting appointment from " + email); //https://aksale.advs.jp/cp/akachan_sale_pc/reg?id=fJrKmJSkXbhtEuAEFWSpeZJ4lfwyV93d string result = Form1.weLoveMuYue( form1, url, "GET", "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi", true, "", ref cookieContainer ); if (!result.Contains("Found")) { form1.setLogtRed("error code from page whose url(" + url + ") getting in" + email); // return -1; } string id = Regex.Match(url, @"(?<=id=).+").Value; string html = Form1.weLoveYue( form1, "https://aksale.advs.jp/cp/akachan_sale_pc/form_card_no.cgi", "POST", "https://aksale.advs.jp/cp/akachan_sale_pc/_reg_form.cgi?id=" + id, //fJrKmJSkXbhtEuAEFWSpeZJ4lfwyV93d", false, "card_no=" + appointment.CardNo + "&sbmt=%8E%9F%82%D6", ref cookieContainer, false ); if (html.Contains("恐れ入りますが、もう一度最初から操作してください")) { form1.setLogtRed("no available quota, url from: " + email); return(-2); } if (html.Contains("正しいカード番号を入力してください")) { form1.setLogtRed("invalid cardNo: " + appointment.CardNo); return(-3); } if (html.Contains("DB接続に失敗しました")) { form1.setLogtRed("oops, something wrong from url in: " + email); return(-4); } html = Form1.weLoveYue( form1, "https://aksale.advs.jp/cp/akachan_sale_pc/reg_form_event_1.cgi" , "POST", "https://aksale.advs.jp/cp/akachan_sale_pc/form_card_no.cgi", false, "password="******"&sei=" + Form1.ToUrlEncode(appointment.ChineseName.Substring(0, 1), System.Text.Encoding.GetEncoding("shift-jis")) + "&mei=" + Form1.ToUrlEncode(appointment.ChineseName.Substring(1, appointment.ChineseName.Length - 1), System.Text.Encoding.GetEncoding("shift-jis")) + "&sei_kana=" + Form1.ToUrlEncode(appointment.JapaneseName.Substring(0, 1), System.Text.Encoding.GetEncoding("shift-jis")) + "&mei_kana=" + Form1.ToUrlEncode(appointment.JapaneseName.Substring(1, appointment.JapaneseName.Length - 1), System.Text.Encoding.GetEncoding("shift-jis")) + "&tel1=" + Regex.Match(appointment.Phone, @"\d+(?=\-)").Value + "&tel2=" + Regex.Match(appointment.Phone, @"(?<=\d+\-)\d+(?=-)").Value + "&tel3=" + Regex.Match(appointment.Phone, @"(?<=\d+\-\d+\-)\d+").Value //"&sei=%9B%C1&mei=%94%F2%94%F2&sei_kana=%83T&mei_kana=%83C%83q%83q&tel1=090&tel2=8619&tel3=3569" + "&sbmt=%8E%9F%82%D6", ref cookieContainer, false ); html = Form1.weLoveYue( form1, "https://aksale.advs.jp/cp/akachan_sale_pc/reg_confirm_event.cgi" , "POST", "https://aksale.advs.jp/cp/akachan_sale_pc/reg_form_event_1.cgi", false, "sbmt=%91%97%90M", ref cookieContainer, false ); if (html.Contains("ご予約ありがとうございます")) { form1.setLogT("CardNo" + appointment.CardNo + ", Setting appointment succeed!");//daiyyr details return(1); } if (html.Contains("予約数に達したため、受付は終了いたしました")) { return(2); } return(1); }