public static string SendRequest(string method, string url, string userAgent, string Referer, string cookie, string contentType, string[] headernames, string[] headers, string data) { WinHttp.WinHttpRequest req = new WinHttpRequest(); try { req.Open(method, url, true); if (String.IsNullOrWhiteSpace(userAgent) == false) req.SetRequestHeader("User-Agent", userAgent); if (String.IsNullOrWhiteSpace(Referer) == false) req.SetRequestHeader("Referer", Referer); if (String.IsNullOrWhiteSpace(cookie) == false) req.SetRequestHeader("Cookie", cookie); if (string.IsNullOrWhiteSpace(contentType) == false) req.SetRequestHeader("Content-Type", contentType); for(int i = 0; i <= headernames.Count(); i++) { if (string.IsNullOrWhiteSpace(headernames[i]) == false && string.IsNullOrWhiteSpace(headers[i]) == false) { req.SetRequestHeader(headernames[i], headers[i]); } } req.Send(data); req.WaitForResponse(); } catch(Exception ex) { return "Error : " + ex.Message.Trim(); } return req.ResponseText; }
public bool login() { Winhttp.Open("POST", "https://dcid.dcinside.com/join/mobile_login_ok.php"); Winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Winhttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"); Winhttp.SetRequestHeader("Referer", "http://m.dcinside.com/login.php?r_url=%2Flist.php%3Fid%3Dhit&rucode=1"); Winhttp.Send("user_id=" + textBox1.Text + "&user_pw=" + textBox2.Text + "&id_chk=on&mode=&id=&r_url=%252Flist.php%253Fid%253Dhit"); Winhttp.WaitForResponse(); Winhttp.Open("GET", "http://m.dcinside.com/list.php?id=hit"); Winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Winhttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"); Winhttp.SetRequestHeader("Referer", "http://m.dcinside.com/login.php?r_url=%2Flist.php%3Fid%3Dhit&rucode=1"); Winhttp.Send(); Winhttp.WaitForResponse(); string data = Winhttp.ResponseText; if (data.IndexOf("logout") != -1) { return(true); } else { return(false); } }
private void button2_Click(object sender, EventArgs e) { listBox1.Items.Clear(); string text = ""; //text = Encoding.UTF8.GetString(textBox2.Text); winhttp.Open("POST", "http://interface518.dothome.co.kr/inter/ADadd.php?"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); winhttp.Send("contents=" + textBox2.Text); winhttp.WaitForResponse(); //textBox1.ToString(); textBox1.Text = Encoding.Default.GetString(winhttp.ResponseBody); }
private bool CheckCorrectLink() { if (!this.materialSingleLineTextField1.Text.StartsWith("http://tvple.com/")) { return(false); } if (!this.materialSingleLineTextField2.Text.StartsWith("http://api.tvple.com/v1/player/cloud/write?")) { return(false); } try { WinHttpRequest Winhttp = new WinHttpRequest(); Winhttp.Open("GET", this.materialSingleLineTextField1.Text); Winhttp.Send(); Winhttp.WaitForResponse(); string result = Encoding.UTF8.GetString(Winhttp.ResponseBody); string[] Separators = new string[] { "fa fa-fw fa-television" }; string[] strResults = result.Split(Separators, StringSplitOptions.None); string[] results1 = strResults[1].Split(new string[] { "</span>" }, StringSplitOptions.None); string[] size = results1[1].Split(new string[] { "</li>" }, StringSplitOptions.None); string finalsize = size[0]; int x = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[0], @"\D", "")); int y = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[1], @"\D", "")); } catch { return(false); } return(true); }
private List <PostListEntity> GetPostList(string url, int page) { try { winhttp.Open("GET", url + "?page=" + page); winhttp.Send(); winhttp.WaitForResponse(); string temp = Strings.Split(winhttp.ResponseText, "<th scope=\"col\">조회수</th>")[1];; int total_post = Convert.ToInt32(Strings.Split(Strings.Split(winhttp.ResponseText, "총 <em>")[1], "</em>")[0]); // 총 게시글 수 int total_pages = (int)(total_post / 20.0 + 0.999); // 총 페이지 수 PageViewModel.GetInstance().MaxPage = total_pages; int notice_size = Strings.Split(temp, "alt=\"공지\"").Length - 1; // 공지사항 개수 int post_size = Strings.Split(temp, "<td class=\"subject\">").Length - 1; // 페이지당 개시글 개수 PostListModel.BoardId = Convert.ToInt32(Strings.Split(Strings.Split(winhttp.ResponseText, "board_id\" value=\"")[1], "\" />")[0]); List <PostListEntity> result = new List <PostListEntity>(); for (int i = 0; i < post_size; i++) { int number = Convert.ToInt32(Strings.Split(Strings.Split(temp, "<td class=\"num\">")[(i + 1) * 2], "</td>")[0]); string title = Strings.Split(Strings.Split(temp, "title=\"")[i + 1], "\">")[0]; if (i < notice_size) { title = "[공지]" + title; } string time = Strings.Split(Strings.Split(temp, "<td class=\"date\">")[i + 1], "</td>")[0]; string publisher = Strings.Split(Strings.Split(temp, "<td class=\"writer\">")[i + 1], "</td>")[0]; int views = Convert.ToInt32(Strings.Split(Strings.Split(temp, "<td class=\"cnt\">")[i + 1], "</td>")[0]); result.Add(new PostListEntity() { Number = number, Title = title, Time = time, Publisher = publisher, Views = views }); } return(result); } catch (Exception ex) { return(new List <PostListEntity>()); } }
private string php(string url) { WinHttpRequest win = new WinHttpRequest(); try { win.Open("GET", url); win.Send(); win.WaitForResponse(); } catch { MessageBox.Show(this, " Server Connection Error", " Debian "); Environment.Exit(0); } return(win.ResponseText); }
public static bool Login(string id, string pw) { WinHttpRequest winhttp = new WinHttpRequest(); winhttp.Open("POST", "https://nid.naver.com/nidlogin.login"); winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0"); if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url")) { return true; } return false; }
public static bool Login(string id, string pw) { WinHttpRequest winhttp = new WinHttpRequest(); winhttp.Open("POST", "https://nid.naver.com/nidlogin.login"); winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0"); if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url")) { return(true); } return(false); }
private void search_Click(object sender, RoutedEventArgs e) { winhttp.Open("POST", "http://interface518.dothome.co.kr/inter/query.php?", false); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); winhttp.Send("id=" + stusearch.Text); winhttp.WaitForResponse(); //textBox1.ToString(); textBox1.Text = Encoding.Default.GetString(winhttp.ResponseBody); if (textBox1.Text.Contains("찾을")) { stustatue.Text = "없는 사람일세"; } else { //listBox1.Items.Add(PersingS(textBox1.Text, "[id] => ", "[") + " " + PersingS(textBox1.Text, "[name] =>", "[") + " " + PersingS(textBox1.Text, "[address] =>", "[") + " " + PersingS(textBox1.Text, " [department] =>", ")")); // stustatue.Text = " " + PersingS(textBox1.Text, "[id] => ", "[") + " " + PersingS(textBox1.Text, "[name] =>", "[") + " " + PersingS(textBox1.Text, "[address] =>", "[") + " " + PersingS(textBox1.Text, " [department] =>", ")"); r_num.Text = PersingS(textBox1.Text, "[id] => ", "["); } r_name.Text = PersingS(textBox1.Text, "[name] =>", "["); r_tele.Text = PersingS(textBox1.Text, "[address] =>", "["); r_dep.Text = PersingS(textBox1.Text, " [department] =>", ")"); }
private void button2_Click(object sender, EventArgs e) { listBox1.Items.Clear(); string text = textBox2.Text; byte[] bSendMsg = Encoding.UTF8.GetBytes(textBox2.Text); string strEncode = HttpUtility.UrlEncode(textBox2.Text); MessageBox.Show(strEncode); string readString = Encoding.UTF8.GetString(bSendMsg); textBox2.Text = readString; //text = Encoding.UTF8.GetString(textBox2.Text); winhttp.Open("POST", "http://interface518.dothome.co.kr/inter/ADadd.php", false); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf8"); winhttp.Send("contents=" + strEncode); winhttp.WaitForResponse(); //textBox1.ToString(); textBox1.Text = Encoding.Default.GetString(winhttp.ResponseBody); /* * string[] parsing = System.Text.RegularExpressions.Regex.Split(winhttp.ResponseText, "<form action=\"http://search.naver.com/search.naver\">"); * * for (int a = 1; a <= 10; a++) * { * string[] parsing1 = parsing[1].Split(new string[] { "<option value=\"" }, 0); * string[] parsing2 = parsing1[a].Split(new string[] { "\"" }, 0); * * listBox1.Items.Add(a + "위 " + parsing2[0]); * }*/ }
/// <summary> /// 登录 /// </summary> private void Login() { try { win.Open("GET", MainUrl + "/mylogin.aspx", false); win.Send(); string strText = win.ResponseText; SetHeaderToHtml(MainUrl + "/mylogin.aspx", 0, strText); } catch (Exception) { } }
void Send_Cloud(string y, string pos, string text, string x) { string _text = "text=" + HttpUtility.UrlEncode(text); string url = headerLink.Split('&')[0] + "&" + headerLink.Split('&')[1]; url += "&text=" + text + "&pos=" + pos + "&x=" + x + "&y=" + y + "&_=" + headerLink.Split('&')[6].Split('=')[1]; WinHttpRequest Winhttp = new WinHttpRequest(); Winhttp.Open("GET", url); //Winhttp.SetRequestHeader("Cookie", this.textBox1.Text); Winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); Winhttp.Send(); //MessageBox.Show(y + "&" + pos + "&" + text + "&" + x); Winhttp.WaitForResponse(); }
public static int GET_NOTI_COUNT(string id, string pw) { try { WinHttpRequest winhttp = new WinHttpRequest(); winhttp.Open("POST", "https://nid.naver.com/nidlogin.login"); winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0"); if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url")) { winhttp.Open("GET", "http://my.naver.com/"); winhttp.Send(); string[] result = winhttp.ResponseText.Split(new string[] { "\"noti\":" }, StringSplitOptions.None); int NOTI_COUNT = Convert.ToInt32(result[1].Split(',')[0]); return(NOTI_COUNT); } return(0); } catch { return(0); } }
public static int GET_NOTI_COUNT(string id, string pw) { try { WinHttpRequest winhttp = new WinHttpRequest(); winhttp.Open("POST", "https://nid.naver.com/nidlogin.login"); winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0"); if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url")) { winhttp.Open("GET", "http://my.naver.com/"); winhttp.Send(); string[] result = winhttp.ResponseText.Split(new string[] { "\"noti\":" }, StringSplitOptions.None); int NOTI_COUNT = Convert.ToInt32(result[1].Split(',')[0]); return NOTI_COUNT; } return 0; } catch { return 0; } }
private string winhttp(string http, string referer) { WinHttpRequest win = new WinHttpRequest(); try { win.Open("GET", http, true); win.SetRequestHeader("Referer", referer); win.Send(); win.WaitForResponse(); } catch { MessageBox.Show(this, "\rServer Connection Error", " Debian "); Environment.Exit(0); } string result = Encoding.UTF8.GetString(win.ResponseBody); return(result); }
public static string php(string url) { WinHttpRequest win = new WinHttpRequest(); try { win.Open("GET", url); win.Send(); win.WaitForResponse(); } catch { MessageBox.Show("Connection Error", "Novah", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } return(win.ResponseText); }
private ApiResult UserQuery(string path, HttpMethod http, Dictionary <string, string> headers = null, string content = "", bool jsonContent = false) { var methodName = http.Method.ToString(); var winHttp = new WinHttpRequest(); path = BaseUri + path; if (methodName == "POST" && content.Length == 0) { throw new ArgumentException("Empty content."); } if (headers != null && headers.Count == 0) { throw new ArgumentException("Empty headers."); } winHttp.Open(methodName, path, true); if (http == HttpMethod.Post) { winHttp.SetRequestHeader("Content-Type", jsonContent ? "application/json" : "application/x-www-form-urlencoded"); } if (headers != null) { foreach (var header in headers) { winHttp.SetRequestHeader(header.Key, header.Value); } } winHttp.Send(content); winHttp.WaitForResponse(); if (winHttp.Status != 200) { throw new InvalidOperationException(String.Format("{0} {1} {2} {3}", winHttp.StatusText, methodName, path, winHttp.ResponseText)); } ParseResponseHeaders(); return(new ApiResult(winHttp.Status, winHttp.ResponseText)); }
public static string SendRequest(string method, string url, string userAgent, string Referer, string cookie, string contentType, string[] headernames, string[] headers, string data) { WinHttp.WinHttpRequest req = new WinHttpRequest(); try { req.Open(method, url, true); if (String.IsNullOrWhiteSpace(userAgent) == false) { req.SetRequestHeader("User-Agent", userAgent); } if (String.IsNullOrWhiteSpace(Referer) == false) { req.SetRequestHeader("Referer", Referer); } if (String.IsNullOrWhiteSpace(cookie) == false) { req.SetRequestHeader("Cookie", cookie); } if (string.IsNullOrWhiteSpace(contentType) == false) { req.SetRequestHeader("Content-Type", contentType); } for (int i = 0; i <= headernames.Count(); i++) { if (string.IsNullOrWhiteSpace(headernames[i]) == false && string.IsNullOrWhiteSpace(headers[i]) == false) { req.SetRequestHeader(headernames[i], headers[i]); } } req.Send(data); req.WaitForResponse(); } catch (Exception ex) { return("Error : " + ex.Message.Trim()); } return(req.ResponseText); }
public void Create(string HttpAddress, string FolderName, int count) { if (HttpAddress.IndexOf("http") > -1 | HttpAddress.IndexOf("https") > -1) { Random rr = new Random(); WinHttpRequest wt = new WinHttpRequest(); for (int i = 0; i < count; i++) { wt.Open("GET", HttpAddress + "?action=MakeDirectory&name=" + FolderName + "_" + DateTime.Now.ToString("mmssff")); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/" + rr.Next(0, 8088)); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Referer", HttpAddress); wt.Send(); Console.WriteLine("[{0}/{1}] SendOK.", i, count); } } else { throw new Exception("http 또는 https 를 포함해야 합니다."); } }
void Get_Size(string link) { WinHttpRequest Winhttp = new WinHttpRequest(); Winhttp.Open("GET", link); Winhttp.Send(); Winhttp.WaitForResponse(); string result = Encoding.UTF8.GetString(Winhttp.ResponseBody); string[] Separators = new string[] { "fa fa-fw fa-television" }; string[] strResults = result.Split(Separators, StringSplitOptions.None); string[] results1 = strResults[1].Split(new string[] { "</span>" }, StringSplitOptions.None); string[] size = results1[1].Split(new string[] { "</li>" }, StringSplitOptions.None); string finalsize = size[0]; int x = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[0], @"\D", "")); int y = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[1], @"\D", "")); this.screen_Size = new System.Drawing.Size(x, y); this.materialLabel3.Text = "Video Size : (" + x.ToString() + "," + y.ToString() + ")"; }
private void NaverCafeLinkButton_Click(object sender, EventArgs e) { // 카페 게시글 http로 읽어오기 naverLoginRequest.Open("GET", "http://m.cafe.naver.com/ArticleList.nhn?search.clubid=11276312&search.menuid=403&search.boardtype=L"); // 웹을 POST로 요청 naverLoginRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); naverLoginRequest.SetRequestHeader("User-Agent", "Mozilla/5.0"); naverLoginRequest.Send(); naverLoginRequest.WaitForResponse(); // 받은 데이터 저장 ncData = naverLoginRequest.ResponseText; this.DebugBox.Text = ncData;// 데이터 임시 미리보기 // 특정 문자열 검색된 경우 String nSerchStr = "<span class=\"ic_new\">New</span>"; // new 게시글의 제목 (해당 문자열) 탐색 if (-1 != ncData.IndexOf(nSerchStr)) { // 해당 문자열 찾은 갯수 카운트 MatchCollection matches = Regex.Matches(ncData, nSerchStr); nFindCount = matches.Count; this.CafeLabel.Text = "카페 게시글 (" + nFindCount.ToString() + "개 찾았습니다)"; // 해당 문자열 갯수만큼 제목 모두 찾기 int seeqCount = 0; // 몇번째 문자열을 찾고 있는지 카운트 int titleCutStart = 0; // 자르기 첫 위치 저장 int titleCutLast = 0; // 자르기 마지막 위치 저장 int urlSeeqCount = 0; int urlTitleCutStart = 0; int urlTitleCutLast = 0; nTitles = new String[nFindCount]; // 찾은 제목을 저장할 배열 nUrlLinks = new String[nFindCount]; // 찾은 URL을 저장할 배열 this.CafeListBox.Items.Clear(); // 리스트박스 초기화 // 게시글 제목과 URL 파스 for (int count = 1; count < nFindCount; count++) { // 제목 찾기 seeqCount = ncData.IndexOf("</strong>", seeqCount + 1); // 찾은 문자열의 해당 번째 위치 반환해 다음 위치 참조 titleCutStart = ncData.IndexOf("<strong>", seeqCount) + 8; // 자르기 첫 위치 추출 titleCutLast = ncData.IndexOf("</strong>", titleCutStart); // 자르기 마지막 위치 추출 // URL 찾기 urlSeeqCount = ncData.IndexOf("<a href=\"/ArticleRead.nhn?", urlSeeqCount + 1); // 찾은 문자열의 해당 번째 위치 반환해 다음 위치 참조 urlTitleCutStart = ncData.IndexOf("<a href=\"/ArticleRead.nhn?", urlSeeqCount) + 10; // 자르기 첫 위치 추출 urlTitleCutLast = ncData.IndexOf("&boardtype=L", urlTitleCutStart); // 자르기 마지막 위치 추출 // 공지가 아닌 경우만 저장 if (-1 == ncData.IndexOf("<span class=\"ic_noti\">공지</span>", titleCutStart, titleCutLast - titleCutStart)) { // 제목 저장 시작 nTitles[count - 1] = ncData.Substring(titleCutStart, titleCutLast - titleCutStart).Trim(); // 제목 텍스트 저장 nTitles[count - 1] = nTitles[count - 1].Replace("\t", ""); // 들여쓰기 제거 nTitles[count - 1] = nTitles[count - 1].Replace("\n", ""); // 개행 제거 nTitles[count - 1] = nTitles[count - 1].Replace(" ", ""); // 개행 제거 // URL 저장 시작 nUrlLinks[count - 1] = ncData.Substring(urlTitleCutStart, urlTitleCutLast - urlTitleCutStart); // 제목 텍스트 저장 this.CafeListBox.Items.Add(nTitles[count - 1]); // 리스트 박스에 출력 } else // 공지가 걸린 경우 배열 카운터 추가 안함 { count--; } } } else { MessageBox.Show("최근 게시글 못찾음"); // 시스템 시간 추출 //MessageBox.Show("현재 시간" + System.DateTime.Now.ToString("hh:mm")); //String nowTime = System.DateTime.Now.ToString("hh:mm"); } }
public string KR(string English) { try { WinHttpRequest wt = new WinHttpRequest(); wt.Open("POST", "https://www.bing.com/translator"); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Content-Type", "text/html; charset=utf-8"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send(); string[] cookie = wt.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None); int cookieCount = 0; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { cookieCount++; } } String[] cookies = new String[cookieCount]; cookieCount = 0; string Fcookie = ""; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { String cookie1 = header.Replace("Set-Cookie: ", ""); cookies[cookieCount] = cookie1; Fcookie += cookie1; } } string mtstkn = "mtstkn=" + Regex.Split(Regex.Split(Fcookie, "mtstkn=")[1], ";")[0] + ";"; string _EDGE_S = "_EDGE_S=" + Regex.Split(Regex.Split(Fcookie, "_EDGE_S=")[1], ";")[0] + ";"; string EDGE_V = "_EDGE_V=" + Regex.Split(Regex.Split(Fcookie, "_EDGE_V=")[1], ";")[0] + ";"; string MUID = "MUID=" + Regex.Split(Regex.Split(Fcookie, "MUID=")[1], ";")[0] + ";"; string MUIDB = "MUIDB=" + Regex.Split(Regex.Split(Fcookie, "MUIDB=")[1], ";")[0] + ";"; Fcookie = ""; Fcookie = mtstkn + _EDGE_S + EDGE_V + MUID + MUIDB; wt.Open("GET", "https://www.bing.com/secure/Passport.aspx?popup=1&ssl=1"); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Content-Type", "text/html; charset=utf-8"); wt.SetRequestHeader("Cookie", Fcookie); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send(); string[] cookie2 = wt.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None); int cookieCount2 = 0; foreach (String header in cookie2) { if (header.StartsWith("Set-Cookie: ")) { cookieCount2++; } } String[] cookies2 = new String[cookieCount2]; cookieCount2 = 0; string Fcookie2 = ""; foreach (String header in cookie2) { if (header.StartsWith("Set-Cookie: ")) { String cookie1 = header.Replace("Set-Cookie: ", ""); cookies2[cookieCount] = cookie1; Fcookie2 += cookie1; } } string SRCHUID = "SRCHUID=" + Regex.Split(Regex.Split(Fcookie, "SRCHUID=")[0], ";")[1] + ";"; string SRCHUSR = "******" + Regex.Split(Regex.Split(Fcookie, "SRCHUSR="******";")[1] + ";"; string _SSSID = "_SS=SID=" + Regex.Split(Regex.Split(Fcookie, "_SS=SID=")[0], ";")[1] + ";"; wt.Open("POST", "https://www.bing.com/translator/api/Translate/TranslateArray?from=en&to=ko"); wt.SetRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Content-Type", "application/json; charset=UTF-8"); wt.SetRequestHeader("Cookie", Fcookie + "destLang=ko; dmru_list=ko; destDia=ko-KR; SRCHD=AF=NOFORM;" + SRCHUID + SRCHUSR + _SSSID + "WLS=C=&N=; srcLang=-; smru_list=; sourceDia=en-US"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send("[{\"id\":2137,\"text\":\"" + English + "\"}]"); return(Regex.Split(Regex.Split(wt.ResponseText, "\"text\": \"")[1], "\",")[0]); } catch { throw new Exception("시스템오류 발생"); } }
private void LoginButton_Click(object sender, RoutedEventArgs e) { WinHttpRequest winhttp = new WinHttpRequest(); winhttp.Open("POST", "https://portal.koreatech.ac.kr/sso/sso_login.jsp"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.Send("user_id=id&user_pwd=pw&RelayState=%2Findex.jsp&id=PORTAL&targetId=PORTAL"); winhttp.WaitForResponse(); string WMONID = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[1], "; ")[0]; string JSessionID = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[2], " Path")[0]; winhttp.Open("POST", "https://portal.koreatech.ac.kr/ktp/login/checkLoginId.do"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); winhttp.SetRequestHeader("Cookie", "WMONID=" + WMONID + "; JSESSIONID=" + JSessionID + " setNowLoginId=id"); winhttp.Send("login_id=id&login_pwd=pw&login_type=&login_empno=&login_certDn=&login_certChannel="); winhttp.WaitForResponse(); if (Strings.Split(Strings.Split(winhttp.ResponseText, "\"result\":\"")[1], "\"")[0] == "true") { int cookie_cnt = Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ").Length - 1; string[] cookies = new string[cookie_cnt]; for (int i = 0; i < cookie_cnt; i++) { cookies[i] = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[i + 1], " Domain")[0]; } winhttp.Open("POST", "https://portal.koreatech.ac.kr/ktp/login/checkSecondLoginCert.do"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); string temp_cookie = WMONID + "; " + JSessionID; string re = temp_cookie; for (int i = 0; i < cookie_cnt; i++) { temp_cookie += " " + cookies[i]; } winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); winhttp.SetRequestHeader("Cookie", temp_cookie); winhttp.Send("login_id=id"); winhttp.WaitForResponse(); re += " setNowLoginId=id;"; for (int i = 0; i < cookie_cnt; i++) { re += " " + cookies[i]; } //re += " kut_login_type=id; Domain=koreatech.ac.kr; Path=/; hostOnly=false;"; re += " kut_login_type=id;"; winhttp.Open("POST", "https://portal.koreatech.ac.kr/exsignon/sso/sso_assert.jsp"); //winhttp.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"); //winhttp.SetRequestHeader("Accept-Encoding","gzip, deflate, br"); //winhttp.SetRequestHeader("Accept-Language","ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7"); //winhttp.SetRequestHeader("Cache-Control","max-age=0"); //winhttp.SetRequestHeader("Connection","keep-alive"); //winhttp.SetRequestHeader("Content-Length","73"); winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); winhttp.SetRequestHeader("Cookie", re); //winhttp.SetRequestHeader("Host","portal.koreatech.ac.kr"); //winhttp.SetRequestHeader("Origin", "https://portal.koreatech.ac.kr"); //winhttp.SetRequestHeader("Referer","https://portal.koreatech.ac.kr/sso/sso_login.jsp"); //winhttp.SetRequestHeader("Sec-Fetch-Dest","document"); //winhttp.SetRequestHeader("Sec-Fetch-Mode","navigate"); //winhttp.SetRequestHeader("Sec-Fetch-Site","same-origin"); //winhttp.SetRequestHeader("Upgrade-Insecure-Request","1"); //winhttp.SetRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"); winhttp.Send("certUserId=&certLoginId=&certEmpNo=&certType=&secondCert=&langKo=&langEn="); winhttp.WaitForResponse(); Console.WriteLine(); } }
public HttpRequest(string Method, string URL, bool Async) { request.Open(Method, URL, Async); }
public bool Post(string DaumID, string DaumPW, string BlogAddress, string title, string content, int categoryID) { try { string Fcookie = ""; title = HttpUtility.UrlEncode(title, Encoding.UTF8); content = HttpUtility.UrlEncode(content, Encoding.UTF8); WinHttpRequest wt = new WinHttpRequest(); wt.Open("GET", "https://logins.daum.net/accounts/presrp.do?id=" + DaumID + "&srpla=" + DaumPW + "&_=1463758848866"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send(); string rid = Regex.Split(Regex.Split(wt.ResponseText, "rid\":\"")[1], "\",\"")[0]; string srplb = Regex.Split(Regex.Split(wt.ResponseText, "srplb\":\"")[1], "\",\"")[0]; wt.Open("POST", "https://logins.daum.net/accounts/msrp.do?rid=" + rid + "&srplm1=" + srplb); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); wt.SetRequestHeader("Referer", "https://logins.daum.net/accounts/msrp.do?rid=" + rid + "&srplm1=" + srplb); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send("url=http%3A%2F%2Fwww.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=" + DaumID + "&pw="); wt.Open("POST", "https://logins.daum.net/accounts/mobile.do"); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); wt.SetRequestHeader("Referer", "https://logins.daum.net/accounts/loginform.do?mobilefull=1&url=http%3A%2F%2Fm.daum.net%3Fnil_rc%3DKZXd2c"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send("url=http%3A%2F%2Fm.daum.net%3Fnil_rc%3DKZXd2c&relative=&mobilefull=1&weblogin=1&id=" + DaumID + "&pw=" + DaumPW); string log = wt.GetResponseHeader("X-DaumLogin-Error"); if (log.IndexOf("200") == -1) { throw new Exception("올바르지 않은 ID 입니다."); } string[] cookie = wt.GetAllResponseHeaders().Split(new string[] { "\n" }, StringSplitOptions.None); int cookieCount = 0; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { cookieCount++; } } String[] cookies = new String[cookieCount]; cookieCount = 0; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { String cookie1 = header.Replace("Set-Cookie: ", ""); Fcookie += cookie1; cookies[cookieCount] = cookie1; } } foreach (string cds in cookies) { Fcookie += cds; } string TS = "TS=\"" + Regex.Split(Regex.Split(Fcookie, "TS=")[1], ";")[0] + "\";"; string HTS = "HTS=\"" + Regex.Split(Regex.Split(Fcookie, "HTS=")[1], ";")[0]; string HM_CU = "HM_CU=\"" + Regex.Split(Regex.Split(Fcookie, "HM_CU=")[1], ";")[0] + "\";"; string PROF = "PROF=\"" + Regex.Split(Regex.Split(Fcookie, "PROF=")[1], ";")[0] + "\";"; string ALID = "ALID=\"" + Regex.Split(Regex.Split(Fcookie, "ALID=")[1], ";")[0] + "\";"; string ALCT = "ALCT=\"" + Regex.Split(Regex.Split(Fcookie, "ALCT=")[1], ";")[0] + "\";"; string LSID = "LSID=\"" + Regex.Split(Regex.Split(Fcookie, "LSID=")[1], ";")[0] + "\";"; string AGEN = "AGEN=\"" + Regex.Split(Regex.Split(Fcookie, "AGEN=")[1], ";")[0] + "\";"; string SLEVEL = "SLEVEL=\"" + Regex.Split(Regex.Split(Fcookie, "SLEVEL=")[1], ";")[0] + "\";"; Fcookie = ""; Fcookie = TS + HTS + HM_CU + PROF + ALID + ALCT + LSID + AGEN + SLEVEL; wt.Open("GET", "http://blog.daum.net/" + BlogAddress); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send(); string blogid = Regex.Split(Regex.Split(wt.ResponseText, "blogid=")[1], "&")[0]; wt.Open("GET", "http://blog.daum.net/_blog/BlogTypeMain.do?blogid=" + blogid.Trim() + "&admin="); wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send(); string articleOpen = Regex.Split(Regex.Split(wt.ResponseText, "articleopen != \"")[1], "\" ")[0]; wt.Open("POST", "http://blog.daum.net/_blog/SimpleEditor.do?blogid=" + blogid.Trim()); wt.SetRequestHeader("Accept", "*/*"); wt.SetRequestHeader("charset", "utf-8"); wt.SetRequestHeader("Cookie", Fcookie); wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do"); wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); wt.Send("articleTitle=" + title + "&article=" + content + "&articleOpen=" + articleOpen + "&categoryID=" + categoryID + "&formName=articleTypeList"); return(true); } catch { throw new Exception("프로그램 오류가 발생 하였습니다.\n(로그인오류 또는 블로그 서비스 이상)"); } }
public bool Post(string NaverID, string NaverPW, string title, string content, int category) { try { content = HttpUtility.UrlEncode(content, Encoding.GetEncoding(949)); title = HttpUtility.UrlEncode(title, Encoding.GetEncoding(949)); WinHttpRequest ht = new WinHttpRequest(); ht.Open("POST", "https://nid.naver.com/nidlogin.login"); ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ht.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login"); ht.Send("enctp=2&url=http://www.naver.com&enc_url=http://www.naver.com&postDataKey=&saveID=0&nvme=0&smart_level=1&id=" + NaverID + "&pw=" + NaverPW); ht.WaitForResponse(); string[] cookie = ht.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None); int cookieCount = 0; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { cookieCount++; } } String[] cookies = new String[cookieCount]; cookieCount = 0; foreach (String header in cookie) { if (header.StartsWith("Set-Cookie: ")) { String cookie1 = header.Replace("Set-Cookie: ", ""); cookies[cookieCount] = cookie1; } } string Fcookie = ""; foreach (string cds in cookies) { Fcookie += cds; } //로그인 종료 ht.Open("GET", "http://blog.naver.com/PostWriteForm.nhn?blogId=" + NaverID + "&Redirect=Write&useSmartEditorVersion=2&redirect=Write&widgetTypeCall=true"); ht.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); ht.SetRequestHeader("Cookie", Fcookie); ht.SetRequestHeader("Host", "blog.naver.com"); ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "?Redirect=Write"); ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); ht.Send(); string blogNo = Regex.Split(Regex.Split(ht.ResponseText, "var blogNo = '")[1], "';")[0]; string nowYear = Regex.Split(Regex.Split(ht.ResponseText, "var nowYear = \"")[1], "\";")[0]; string nowMount = Regex.Split(Regex.Split(ht.ResponseText, "var nowMonth = \"")[1], "\";")[0]; string nowDate = Regex.Split(Regex.Split(ht.ResponseText, "var nowDate = \"")[1], "\";")[0]; string nowHour = Regex.Split(Regex.Split(ht.ResponseText, "var nowHour = \"")[1], "\";")[0]; string nowMinute = Regex.Split(Regex.Split(ht.ResponseText, "var nowMinute = \"")[1], "\";")[0]; string editorSource = Regex.Split(Regex.Split(ht.ResponseText, "name=\"editorSource\" value=\"")[1], "\">")[0]; ht.Open("POST", "http://blog.naver.com/TempPostWriteAsync.nhn"); ht.SetRequestHeader("Accept", "*/*"); ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); ht.SetRequestHeader("Cookie", Fcookie); ht.SetRequestHeader("Host", "blog.naver.com"); ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "/postwrite"); ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); string postdata = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=&post.sourceCode=0&post.contents.contentsValue=" + content + "&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=true&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=%0A%0A&query=%EC%A7%80%EC%97%AD%EB%AA%85%EC%9D%84%20%EC%9E%85%EB%A0%A5%ED%95%B4%20%EC%A3%BC%EC%84%B8%EC%9A%94&char_preview=%C2%AE%C2%BA%E2%8A%86%E2%97%8F%E2%97%8B&se2_tbp=on&se2_tbp3=on&=on&post.directorySeq=0&post.tag.names=%ED%83%9C%EA%B7%B8%EC%99%80%20%ED%83%9C%EA%B7%B8%EB%8A%94%20%EC%89%BC%ED%91%9C%EB%A1%9C%20%EA%B5%AC%EB%B6%84%ED%95%98%EB%A9%B0%2C%2010%EA%B0%9C%EA%B9%8C%EC%A7%80%20%EC%9E%85%EB%A0%A5%ED%95%98%EC%8B%A4%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.&openType=2&post.postWriteTimeType=now&prePostDay=" + DateTime.Now.ToString("yyyy년 MM월 dd일") + "&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=&prePostDateType.month=&prePostDateType.date=&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D"; ht.Send(postdata); string postlogNo = ht.ResponseText; ht.Open("POST", "http://blog.naver.com/PostWrite.nhn"); ht.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); ht.SetRequestHeader("Accept-Encoding", "deflate"); ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"); ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ht.SetRequestHeader("Cookie", Fcookie); ht.SetRequestHeader("Host", "blog.naver.com"); ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "/postwrite"); ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); //string postdata2 = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=" + postlogNo + "&post.sourceCode=0&post.contents.contentsValue=<p>" + content + "</p>&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=true&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=<p>" + content + "</p>&query=%C1%F6%BF%AA%B8%ED%C0%BB+%C0%D4%B7%C2%C7%D8+%C1%D6%BC%BC%BF%E4&char_preview=%A2%E7%A8%AC%A1%F6%A1%DC%A1%DB&se2_tbp=on&se2_tbp3=on&post.directorySeq=0&post.tag.names=&openType=2&post.postWriteTimeType=now&prePostDay=2016%B3%E2+5%BF%F9+18%C0%CF&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=" + nowYear + "&prePostDateType.month=" + nowMount + "&prePostDateType.date=" + nowDate + "&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D"; string postdata2 = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=" + postlogNo + "&post.sourceCode=0&post.contents.contentsValue=" + content + "&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=false&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=" + content + "&query=%C1%F6%BF%AA%B8%ED%C0%BB+%C0%D4%B7%C2%C7%D8+%C1%D6%BC%BC%BF%E4&char_preview=%A2%E7%A8%AC%A1%F6%A1%DC%A1%DB&se2_tbp=on&se2_tbp3=on&post.directorySeq=0&post.tag.names=&openType=2&post.postWriteTimeType=now&prePostDay=2016%B3%E2+5%BF%F9+22%C0%CF&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=" + nowYear + "&prePostDateType.month=" + nowMount + "&prePostDateType.date=" + nowDate + "&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D"; ht.Send(postdata2); if (ht.ResponseText.IndexOf("refresh") != -1) { return(true); } else { if (ht.ResponseText.IndexOf("비정상적") != -1) { Console.WriteLine("[E01] 네이버 블로그서비스 에서 등록거부를 Return 받았습니다."); } return(false); } } catch { return(false); } }
private void ItemRefreshButton_Click(object sender, EventArgs e) { // 아이템매니아 게시글 http로 읽어오기 itemLoginRequest.Open("POST", "http://trade.itemmania.com/sell/list.html"); // 웹을 POST로 요청 itemLoginRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); itemLoginRequest.SetRequestHeader("User-Agent", "Mozilla/5.0"); String iSendString = "search_type=sell&" + "search_game=281&" + "search_goods=all&" + "search_word=" + this.ItemSearch.Text; itemLoginRequest.Send(iSendString); itemLoginRequest.WaitForResponse(); itData = itemLoginRequest.ResponseText; // 아이템매니아로부터 받은 데이터 저장 this.DebugBox.Text = itData; // 데이터 임시 미리보기 // 특정 문자열 검색된 경우 String iSerchStr = "<td class=\"first \">"; // new 게시글의 제목 (해당 문자열) 탐색 if (-1 != itData.IndexOf(iSerchStr)) { // 해당 문자열 찾은 갯수 카운트 MatchCollection matches = Regex.Matches(itData, iSerchStr); iFindCount = matches.Count; this.ItemLabel.Text = "아이템매니아 게시글 (" + iFindCount.ToString() + "개 찾았습니다)"; // 해당 문자열 갯수만큼 제목 모두 찾기 int seeqCount = 0; // 몇번째 문자열을 찾고 있는지 카운트 int titleCutStart = 0; // 자르기 첫 위치 저장 int titleCutLast = 0; // 자르기 마지막 위치 저장 int urlCutStart = 0; // 자르기 첫 위치 저장 int urlCutLast = 0; // 자르기 마지막 위치 저장 iTitles = new String[iFindCount]; // 찾은 제목을 저장할 배열 iFinalTitles = new String[iFindCount]; // 완성한 제목을 저장할 배열 iUrlLinks = new String[iFindCount]; // URL을 저장할 배열 this.ItemListBox.Items.Clear(); // 리스트박스 초기화 // 게시글 제목 파스 for (int count = 0; count < iFindCount; count++) { // 카테고리 찾아서 저장 seeqCount = itData.IndexOf(iSerchStr, seeqCount + 1); // 찾은 문자열의 해당 번째 위치 반환해 다음 위치 참조 titleCutStart = itData.IndexOf("<td class=\"first \">", seeqCount) + 19; // 자르기 첫 위치 추출 titleCutLast = itData.IndexOf("<td class=\" \">", titleCutStart); // 자르기 마지막 위치 추출 if (titleCutLast == -1) // 마지막 위치 추출 불가할 경우 { MessageBox.Show("검색이 불가능한 단어"); // 검색 오류 break; } iTitles[count] = itData.Substring(titleCutStart, titleCutLast - titleCutStart).Trim(); // 카테고리 텍스트 저장 iTitles[count] = iTitles[count].Replace("\t", ""); // 들여쓰기 제거 iTitles[count] = iTitles[count].Replace("\n", ""); // 개행 제거 // URL 찾아서 저장 urlCutStart = iTitles[count].IndexOf("onclick=\"$.fnViewId('") + 21; // 자르기 첫 위치 추출 urlCutLast = iTitles[count].IndexOf("');\" class=\"\">", urlCutStart); // 자르기 마지막 위치 추출 iUrlLinks[count] = iTitles[count].Substring(urlCutStart, urlCutLast - urlCutStart); // 카테고리 텍스트 저장 // 카테고리중 서버만 전부 검색해 추출 if (-1 != iTitles[count].IndexOf("스타트")) { iFinalTitles[count] = "스타트/ "; } else if (-1 != iTitles[count].IndexOf("디레지에")) { iFinalTitles[count] = "디레지/ "; } else if (-1 != iTitles[count].IndexOf("바칼")) { iFinalTitles[count] = "바칼 / "; } else if (-1 != iTitles[count].IndexOf("시로코")) { iFinalTitles[count] = "시로코/ "; } else if (-1 != iTitles[count].IndexOf("안톤")) { iFinalTitles[count] = "안톤 / "; } else if (-1 != iTitles[count].IndexOf("카시야스")) { iFinalTitles[count] = "카시야/ "; } else if (-1 != iTitles[count].IndexOf("카인")) { iFinalTitles[count] = "카인 / "; } else if (-1 != iTitles[count].IndexOf("프레이")) { iFinalTitles[count] = "프레이/ "; } else if (-1 != iTitles[count].IndexOf("힐더")) { iFinalTitles[count] = "힐더 / "; } else if (-1 != iTitles[count].IndexOf("이벤트 서버")) { iFinalTitles[count] = "이벤트/ "; } else { iFinalTitles[count] = "기타 / "; } // 판매금액만 추출 if (-1 != iTitles[count].IndexOf("<td class=\"s_right g_red1\">")) { // 특정 문자열 검색된 경우 필요한 문자열만 찾아서 저장 titleCutStart = iTitles[count].IndexOf("<td class=\"s_right g_red1\">") + 28; // 자르기 첫 위치 추출 titleCutLast = iTitles[count].IndexOf("</td>", titleCutStart); // 자르기 마지막 위치 추출 iFinalTitles[count] += iTitles[count].Substring(titleCutStart, titleCutLast - titleCutStart).Trim() + " "; // 제목 텍스트 저장 } // 제목 내용만 추출 if (-1 != iTitles[count].IndexOf(" ")) { // 특정 문자열 검색된 경우 필요한 문자열만 찾아서 저장 titleCutStart = iTitles[count].LastIndexOf(" ") + 6; // 자르기 첫 위치 추출 titleCutLast = iTitles[count].IndexOf("</a>", titleCutStart); // 자르기 마지막 위치 추출 iFinalTitles[count] += iTitles[count].Substring(titleCutStart, titleCutLast - titleCutStart).Trim(); // 제목 텍스트 저장 } else // 그 밖에 특수한 상황 { // 특정 문자열 검색된 경우 필요한 문자열만 찾아서 저장 titleCutStart = iTitles[count].LastIndexOf("');\" class=\"\">") + 14; // 자르기 첫 위치 추출 titleCutLast = iTitles[count].IndexOf("</a>", titleCutStart); // 자르기 마지막 위치 추출 iFinalTitles[count] += iTitles[count].Substring(titleCutStart, titleCutLast - titleCutStart).Trim(); // 제목 텍스트 저장 } // 필요없는 기능문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("'", ""); // ' 제거 iFinalTitles[count] = iFinalTitles[count].Replace("</span>", ""); // </span> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("</font>", ""); // </font> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("<font class='g_blue1'>", ""); // <font class='g_blue1'> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("<span class='bold_txt'>", ""); // <span class='bold_txt'> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("<span class='list_highlight'>", ""); // <span class='list_highlight'> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("<span style='color:#298B7C'>", ""); // <span style='color:#298B7C'> 제거 iFinalTitles[count] = iFinalTitles[count].Replace("█", ""); // █ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("◘", ""); // ◘ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("■", ""); // ■ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("◆", ""); // ◆ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("★", ""); // █ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("◀", ""); // ◀ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("●", ""); // ● 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("▶", ""); // ▶ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("◁", ""); // ◁ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("○", ""); // ○ 문자 제거 iFinalTitles[count] = iFinalTitles[count].Replace("▷", ""); // ▷ 문자 제거 // 리스트 추가 this.ItemListBox.Items.Add(iFinalTitles[count]); } } else { MessageBox.Show("최근 게시글 못찾음"); // 시스템 시간 추출 //MessageBox.Show("현재 시간" + System.DateTime.Now.ToString("hh:mm")); //String nowTime = System.DateTime.Now.ToString("hh:mm"); } }
private void NaverLoginButton_Click(object sender, EventArgs e) // 버튼이 클릭됬을때 발생되는 이벤트 { Form2 form2 = new Form2(this); // 게시글 표시용 폼 생성 bool isILoginSucess = false; // 아이템매니아 로그인 성공 여부 저장 // 네이버 로그인 시작 String nID = this.NaverLoginId.Text; String nPW = this.NaverLoginPw.Text; String nSendString = "enctp=1" + "&encpw=0" + "&encnm=0" + "&svctype=0" + "&svc=0" + "&viewtype=0" + "&postDataKey=0" + "&smart_LEVEL=-1" + "&logintp=0" + "&localechange=0" + "&theme_mode=0" + "&ls=0" + "&pre_id=0" + "&resp=0" + "&exp=0" + "&ru=0" + "&id=" + nID + "&pw=" + nPW + "&nvlong=on"; if (nID != "") // 아이디를 적은 경우만 로그인 시도 { naverLoginRequest.Open("POST", "https://nid.naver.com/nidlogin.login"); // 웹을 POST로 요청 naverLoginRequest.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login"); // 헤더 할당 naverLoginRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); naverLoginRequest.SetRequestHeader("User-Agent", "Mozilla/5.0"); naverLoginRequest.Send(nSendString); // 문자열 전송 naverLoginRequest.WaitForResponse(); String nLoginData = naverLoginRequest.ResponseText; // 네이버 로부터 받은 데이터 저장 if (-1 == nLoginData.IndexOf("window.location.replace")) // 네이버 로그인에 실패한 경우 { MessageBox.Show("네이버 로그인 실패"); } } // 아이템매니아 로그인 시작 String iID = this.ItemLoginId.Text; String iPW = this.ItemLoginPw.Text; String iSendString = "plogin_kr=0" + "&user_id=" + iID + "&user_password="******"&id_save=ok"; if (iID != "") // 아이디를 적은 경우만 로그인 시도 { itemLoginRequest.Open("POST", "https://www.itemmania.com/portal/user/login_form_ok.php"); // 웹을 POST로 요청 itemLoginRequest.SetRequestHeader("Referer", "https://www.itemmania.com/portal/user/p_login_form.html"); // 헤더 할당 itemLoginRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); itemLoginRequest.SetRequestHeader("User-Agent", "Mozilla/5.0"); itemLoginRequest.Send(iSendString); // 문자열 전송 itemLoginRequest.WaitForResponse(); String iLoginData = itemLoginRequest.ResponseText; // 아이템매니아 로부터 받은 데이터 저장 if (-1 == iLoginData.IndexOf("location.href='http://www.itemmania.com'")) // 아이템매니아 로그인에 성공한 경우 { MessageBox.Show("아이템매니아 로그인 실패"); } else { isILoginSucess = true; // 로그인 성공 여부 저장 } } else { MessageBox.Show("최소한 아이템매니아 로그인은 필요합니다"); } // 로그인이 성공한 경우 if (isILoginSucess == true) { // 폼 전환 this.Hide(); form2.Show(); // 폼 2 에 winhttp 인스턴스를 넘김 form2.SetLoginInfo(this, naverLoginRequest, itemLoginRequest); } }