private void LoginButton_Click(object sender, EventArgs e) { string username; string password; username = UserNameTextBox.Text.ToString(); password = PasswordTextBox.Text.ToString(); //if (username != "" || password != "") //{ NetWorkOperation.Login(username, password); //} //else //{ // MessageBox.Show("用户名或密码不能为空!"); //} }
private void button1_Click(object sender, EventArgs e) { //BalancedSearchTree tree = new BalancedSearchTree(int.MinValue); //tree.insertTree(tree, 10); //tree.insertTree(tree, 5); //tree.insertTree(tree, 13); //tree.insertTree(tree, 2); //tree.insertTree(tree, 7); //tree.insertTree(tree, 4); //tree.insertTree(tree, 6); //tree.insertTree(tree, 3); //Boolean a=tree.Search(tree, 6); int id = 73915; String url = ""; int end = 0; int start = 0; for (int i = id; i < 75001; i += 2) { end = 0; start = 0; try { url = "http://www.fmdisk.com/file-" + i + ".html"; string str = ""; str = NetWorkOperation.GetHtmlMetheod(url); start = str.IndexOf("keywords", end); start += 19; end = str.IndexOf(".", start); string name = str.Substring(start, end - start); Console.WriteLine(i + "-" + name); if (name.Equals("S1492539 DZ")) { MessageBox.Show("That's it!"); } } catch (System.Exception ex) { Console.WriteLine("error" + i); continue; } } MessageBox.Show("ALL over!"); }
public List <string> GetFriendID() { int index1 = 0; Boolean isEnough = false; //string statue; //friendId = FriendIDBox.Text.ToString(); //StreamWriter sw1=new StreamWriter("d:\\456.txt"); int start; int end = 0; int nameStart = 0; int nameEnd = 0; int start1; int end1 = 0; int page = 0; int finalpage = 1; int renshu = 0; do { start = 0; end = 0; nameStart = 0; nameEnd = 0; try { string childUrl = "http://friend.renren.com/GetFriendList.do?curpage=" + page + "&id=" + this.ID; string str = ""; #region get html source code //GetHtml getChildHtml = new GetHtml(childUrl, GlobalData.cookiesstr, GlobalData.cc); //str = getChildHtml.GetHtmlMetheod(childUrl); str = NetWorkOperation.GetHtmlMetheod(childUrl); //Console.Write(str); //sw1.Write(str); //sw1.Close(); #endregion while (str != null) { #region get the number of total pages start1 = str.IndexOf("最后页", end1); if (page == 0 && start1 != -1) { end1 = str.IndexOf('&', start1); if (end1 - start1 - 37 < 0) { page++; continue; } string number = str.Substring(start1 + 37, (end1 - start1 - 37)); finalpage = int.Parse(number); } #endregion #region get the friend id int a; start = str.IndexOf("onclick=\"return doPoke(event,'", end); if (start != -1) { end = str.IndexOf("','", start); string number = str.Substring(start + 30, (end - start - 30)); try { int[] addStatue; a = int.Parse(number); //nameStart = str.IndexOf(number.ToString() + "\',", end); int nameLength = number.Length; nameEnd = str.IndexOf("')", end); string childName = str.Substring(end + 3, nameEnd - end - 3); //findFriendInList(number); friendList.Add(number); //检测原来是否添加过是否为好友 addStatue = GlobalData.T.Search(GlobalData.T, int.Parse(number)); if (addStatue[1] == 0) { //int[] addStatue = { int.Parse(number), 0, 0 }; GlobalData.AllFriendIDList.Add(number); GlobalData.index++; GlobalData.rootFriend.AddFriend(number); GlobalData.currentID2 = index1; index1++; GlobalData.addFriendForm.Invoke(GlobalData.addFriendForm.AddFriendDelegate, new object[] { ID + "饕" + name + "饕" + number + "饕" + childName + "饕" + addStatue[1] + "饕" + addStatue[2] }); GlobalData.T.insertTree(GlobalData.T, addStatue); } else if (addStatue[1] == 1) { GlobalData.addFriendForm.Invoke(GlobalData.addFriendForm.AddFriendDelegate, new object[] { ID + "饕" + name + "饕" + number + "饕" + childName + "饕" + addStatue[1] + "饕" + addStatue[2] }); } if (GlobalData.index >= GlobalData.count) { isEnough = true; break; } } catch (Exception e) { Console.WriteLine(e.ToString()); continue; } } else { break; } #endregion } if (isEnough == true) { break; } page++; #region print out the number of friends of each page if (renshu == 0) { renshu = friendList.Count; Console.WriteLine("this page has " + friendList.Count + "friends"); } else { Console.WriteLine("this page has " + (friendList.Count - renshu).ToString() + "friends"); renshu = friendList.Count; } #endregion } catch (Exception Ex) { Console.WriteLine(Ex.Message.ToString()); throw Ex; } } while (page != finalpage + 1); #region out put the friends id txt //string outPutPath = "D://inspiration//FriendNet//" + ID + "-Id.txt"; //StreamWriter sw = new StreamWriter(outPutPath, true); //foreach (string id in friendList) //{ // //AllFriendIdBox.Text += id.ToString() + "\r\n"; // sw.WriteLine(id); //} //sw.Close(); #endregion Console.WriteLine("Your friend has " + friendList.Count + " friends"); return(friendList); }
public void GetMyFriendID() { int start; int end = 0; //int nameStart = 0; int nameEnd = 0; int countStart = 0; int countEnd = 0; int start1; int end1 = 0; int page = 0; int finalpage = 1; int renshu = 0; int friendcount; do { start = 0; end = 0; //nameStart = 0; nameEnd = 0; try { string childUrl = "http://friend.renren.com/GetFriendList.do?curpage=" + page + "&id=" + this.ID; string str = ""; #region get html source code //GetHtml getChildHtml = new GetHtml(childUrl, GlobalData.cookiesstr, GlobalData.cc); //str = getChildHtml.GetHtmlMetheod(childUrl); str = NetWorkOperation.GetHtmlMetheod(childUrl); //Console.Write(str); //sw1.Write(str); //sw1.Close(); #endregion while (str != null) { countStart = str.IndexOf("\"count\">", end1); countStart += "\"count\"".Length; countEnd = str.IndexOf("</", countStart); friendcount = int.Parse(str.Substring(countStart + 1, countEnd - countStart - 1)); GlobalData.addFriendForm.Invoke(GlobalData.addFriendForm.SetLabelDelegate, new object[] { friendcount.ToString() }); #region get the number of total pages start1 = str.IndexOf("最后页", countEnd); if (page == 0 && start1 != -1) { end1 = str.IndexOf('&', start1); if (end1 - start1 - 37 < 0) { page++; continue; } string number = str.Substring(start1 + 37, (end1 - start1 - 37)); finalpage = int.Parse(number); } #endregion #region get the friend id int a; start = str.IndexOf("onclick=\"return doPoke(event,'", end); if (start != -1) { end = str.IndexOf("','", start); string number = str.Substring(start + 30, (end - start - 30)); try { a = int.Parse(number); int[] addstatue = { int.Parse(number), 1, 1 }; //nameStart = str.IndexOf("','", end); int nameLength = number.Length; nameEnd = str.IndexOf("')", end); string childName = str.Substring(end + 3, nameEnd - end - 3); GlobalData.T.insertTree(GlobalData.T, addstatue); GlobalData.addFriendForm.Invoke(GlobalData.addFriendForm.FriendDelegate, new object[] { number + "饕" + childName + "饕" + "NO" }); } catch (Exception e) { Console.WriteLine(e.ToString()); continue; } } else { break; } #endregion } page++; #region print out the number of friends of each page if (renshu == 0) { renshu = friendList.Count; Console.WriteLine("this page has " + friendList.Count + "friends"); } else { Console.WriteLine("this page has " + (friendList.Count - renshu).ToString() + "friends"); renshu = friendList.Count; } #endregion } catch (Exception Ex) { Console.WriteLine(Ex.Message.ToString()); throw Ex; } } while (page != finalpage + 1); }