public static string GetMacAddress() { string mac = string.Empty; try { IPAddress dst = IPAddress.Parse(InstagramCommon.GetLocalIP()); // the destination IP address byte[] macAddr = new byte[6]; uint macAddrLen = (uint)macAddr.Length; if (SendARP(BitConverter.ToInt32(dst.GetAddressBytes(), 0), 0, macAddr, ref macAddrLen) != 0) { throw new InvalidOperationException("SendARP failed."); } string[] str = new string[(int)macAddrLen]; for (int i = 0; i < macAddrLen; i++) { str[i] = macAddr[i].ToString("x2"); } mac = string.Join(":", str); } catch { } return(mac); }
//언팔로우 작업 public bool ExecuteUnFollow(string ID) { bool flag = true; try { //ID 에 해당하는 페이지를 찾아가서 팔로잉 이있을경우 팔로잉을 클릭하여 업팔로우 처리를 합니다. this.driver.Navigate().GoToUrl("https://www.instagram.com/" + ID + "/"); InstagramCommon.Dela2(2); string tmpSource = this.driver.PageSource.Split(new string[] { "<button class=\"" }, StringSplitOptions.RemoveEmptyEntries)[1]; tmpSource = tmpSource.Split(new string[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[0]; //팔로잉이 있을경우는 이미 팔로우 하고 있는경우이므로 다시 클릭하여 언팔로우 처리를합니다. if (this.driver.FindElement(By.XPath("//button[@class='" + tmpSource + "']")).GetAttribute("outerText").IndexOf("팔로잉") >= 0) { this.driver.FindElement(By.XPath("//button[@class='" + tmpSource + "']")).Click(); } } catch (Exception ex) { flag = false; } return(flag); }
public InstagramHandler() { SpamList = InstagramCommon.GetSpamList(); ReplyList = InstagramCommon.GetReplyList(); FollowList = InstagramCommon.GetFollowList(); LikeList = InstagramCommon.GetLikeList(); }
//public bool Getunfollow() //{ // bool flag; // this.driver.FindElement(By.XPath("//a[@class='instagram signin-button']")).Click(); // Common.Dela2(1); // this.driver.FindElement(By.XPath("//ul[@class='uf-navbar-nav nav']/li[2]/a/span[2]")).Click(); // Common.Dela2(1); // int index = 1; // do // { // this.ScrollDown(); // Common.Dela2(1); // index++; // } // while (index <= 60); // Common.Dela2(5); // //string[] array = Strings.Split(this.driver.PageSource, "<span class=\"username\"", -1, CompareMethod.Binary); // //MyProject.Forms.INSTA.ListBox4.Items.Clear(); // //int num2 = Information.UBound(array, 1); // // for (index = 1; index <= num2; index++) // //{ // //MyProject.Forms.INSTA.ListBox4.Items.Add(Strings.Split(Strings.Split(array[index], "@", -1, CompareMethod.Binary)[1], "<", -1, CompareMethod.Binary)[0]); // //Application.DoEvents(); // // } // return flag; //} //public bool GOTOURL(string Str) //{ // bool flag; // this.driver.Navigate().GoToUrl(Str); // return flag; //} ////언팔로우 //public bool HateFollow(string ID) //{ // bool flag; // //ID 에 해당하는 페이지를 찾아가서 팔로잉 이있을경우 팔로잉을 클릭하여 업팔로우 처리를 합니다. // this.driver.Navigate().GoToUrl("https://www.instagram.com/" + ID + "/"); // Common.Dela2(2); // string tmpSource = this.driver.PageSource.Split(new string[] { "<button class=\"" }, StringSplitOptions.RemoveEmptyEntries)[1]; // tmpSource = tmpSource.Split(new string[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[0]; // //팔로잉이 있을경우는 이미 팔로우 하고 있는경우이므로 다시 클릭하여 언팔로우 처리를합니다. // if (this.driver.FindElement(By.XPath("//button[@class='" + tmpSource + "']")).GetAttribute("outerText").IndexOf("팔로잉") >= 0) // { // this.driver.FindElement(By.XPath("//button[@class='" + tmpSource + "']")).Click(); // } // return flag; //} //public bool IDCheck(ListView LV) //{ // bool flag; // int num4 = LV.Items.Count - 1; // for (int i = 0; i <= num4; i++) // { // if (this.driver.PageSource.IndexOf("\">" + LV.Items[i].Text + "</a><span") >= 0) // { // flag = true; // break; // } // flag = false; // } // return flag; //} //사용안함 public bool InLike() { bool flag; InstagramCommon.Dela2(3); this.driver.FindElement(By.XPath("//a[@class='-cx-PRIVATE-PostInfo__likeButton -cx-PRIVATE-LikeButton__root -cx-PRIVATE-Util__hideText coreSpriteHeartOpen']")).Click(); flag = true; return(flag); }
//좋아요 실행 public bool Likes() { bool flag; InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/a")).Click(); flag = true; return(flag); }
//답글작성 public bool Replys(string Str) { bool flag; InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).Click(); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).SendKeys(Str); InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).SendKeys(OpenQA.Selenium.Keys.Enter); flag = true; return(flag); }
//로그인 public bool login_IN(string ID, string PW) { InstagramCommon.Dela2(5); this.driver.FindElement(By.Name("username")).Click(); this.driver.FindElement(By.Name("username")).SendKeys(ID); this.driver.FindElement(By.XPath("//input[@name='password' and @placeholder='비밀번호']")).SendKeys(PW); //string str = Strings.Split(Strings.Split(this.driver.PageSource, "<button class=\"", -1, CompareMethod.Binary)[1], "\"", -1, CompareMethod.Binary)[0]; string str = this.driver.PageSource.Split(new string[] { "<button class=\"" }, StringSplitOptions.RemoveEmptyEntries)[1]; str = str.Split(new string[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[0]; this.driver.FindElement(By.XPath("//button[@class='" + str + "']")).Click(); return(true); }
public bool CheckID(string ID) { bool flag; InstagramCommon.Dela2(5); if (this.driver.PageSource.IndexOf("href=\"/" + ID + "/\"") >= 0) { flag = true; } else { flag = false; } return(flag); }
//해시 태그로 검색 public bool ExecuteSearch(string searchText) { bool flag = true; try { InstagramCommon.Dela2(5); this.driver.Navigate().GoToUrl("https://instagram.com/explore/tags/" + searchText + "/"); InstagramCommon.Dela2(5); } catch (Exception ex) { flag = false; } return(flag); }
//좋아요 클릭 public bool LikeClick() { bool flag = true; try { InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/a")).Click(); } catch (Exception ex) { flag = false; } return(flag); }
////해시 태그로 검색 //public bool Seach_IN(string Str) //{ // bool flag; // Common.Dela2(5); // this.driver.Navigate().GoToUrl("https://instagram.com/explore/tags/" + Str + "/"); // Common.Dela2(5); // return flag; //} //검색된 거 선택 public bool SelectPic() { bool flag; int num = 2; InstagramCommon.Dela2(5); string[] array = this.driver.PageSource.Split(new string[] { "href=\"/p" }, StringSplitOptions.RemoveEmptyEntries); //MyProject.Forms.INSTA.ListBox1.Items.Clear(); //int num4 = Information.UBound(array, 1); //for (int i = 1; i <= num4; i++) //{ // string item = "/p/" + Strings.Split(Strings.Split(array[i], "/", -1, CompareMethod.Binary)[1], "\"", -1, CompareMethod.Binary)[0]; // MyProject.Forms.INSTA.ListBox1.Items.Add(item); //} flag = true; return(flag); }
//댓글을 작성합니다. public bool WriteReply(string reply) { bool flag = true; try { InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).Click(); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).SendKeys(reply); InstagramCommon.Dela2(5); this.driver.FindElement(By.XPath("//article[@class='" + this.ArtCl + "']/div[2]/section[2]/form/input")).SendKeys(OpenQA.Selenium.Keys.Enter); } catch (Exception ex) { flag = false; } return(flag); }
//로그인 버튼을 클릭합니다. public bool LoginClick(string ID, string PW) { bool flag = true; try { InstagramCommon.Dela2(5); this.driver.FindElement(By.Name("username")).Click(); this.driver.FindElement(By.Name("username")).SendKeys(ID); this.driver.FindElement(By.XPath("//input[@name='password' and @placeholder='비밀번호']")).SendKeys(PW); string str = this.driver.PageSource.Split(new string[] { "<button class=\"" }, StringSplitOptions.RemoveEmptyEntries)[1]; str = str.Split(new string[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[0]; this.driver.FindElement(By.XPath("//button[@class='" + str + "']")).Click(); } catch (Exception ex) { flag = false; } return(flag); }
private void addButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(userNameTextBox.Text) == true) { MessageBox.Show("사용자명이 없습니다.\r\n사용자명을 입력해주세요", "입력", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(telNumberTextBox.Text) == true) { MessageBox.Show("전화번호가 없습니다.\r\n전화번호를 입력해주세요", "입력", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string macAddress = macAddressTextBox.Text; string userName = userNameTextBox.Text; string telNumber = telNumberTextBox.Text; string result = InstagramCommon.AddInstagramMacAddressInfo(macAddress, userName, telNumber); string message = string.Empty; switch (result) { case "001": message = "사용자 등록이 정상적으로 처리되었습니다.\r\n관리자에게 사용등록을 요청하세요."; _isRegister = true; break; case "002": message = "이미 등록된 사용자입니다."; break; case "003": message = "사용자등록중 에러가 발생했습니다."; break; } MessageBox.Show(message, "완료", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
//검색된 거 선택 public bool SelectPictuer() { bool flag = true; try { InstagramCommon.Dela2(5); string[] array = this.driver.PageSource.Split(new string[] { "href=\"/p" }, StringSplitOptions.RemoveEmptyEntries); boardURLList.Clear(); foreach (string value in array) { string tempItem = value.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries)[1]; tempItem = "/p/" + tempItem.Split(new string[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[0]; boardURLList.Add(tempItem); } } catch (Exception ex) { flag = false; } return(flag); }
public frmUserRegister() { InitializeComponent(); macAddressTextBox.Text = InstagramCommon.GetMacAddress(); }