示例#1
0
        private void GetAlbumNumber(string url, string Id)
        {
            int           start;
            int           end         = 0;
            int           albumCount  = 0;
            GetHtml       getHtml     = new GetHtml(url, Cookiesstr, cc);
            List <string> albumIdList = new List <string>();
            string        str         = getHtml.GetHtmlMetheod();

            //Console.WriteLine(str);
            while (str != null)
            {
                start = str.IndexOf("/album-", end);
                if (start != -1)
                {
                    end = str.IndexOf("?", start);
                    string number = str.Substring(start + 7, (end - start - 7));

                    try
                    {
                        if (albumCount % 2 == 0)
                        {
                            albumIdList.Add(number);
                        }
                        albumCount++;
                    }
                    catch
                    {
                        continue;
                    }
                }
                else
                {
                    break;
                }
            }
            //foreach (string i in albumIdList)
            //{
            //    Console.WriteLine("album id=" + i);
            //}
            string       outPutPath = "I://lcj//" + friendId + "albumList.txt";
            StreamWriter sw         = new StreamWriter(outPutPath, true);

            sw.WriteLine("id " + Id);
            FileName fileName = new FileName(Id);

            fileName.ablumIdList = albumIdList;
            fileNameList.Add(fileName);
            foreach (string album in albumIdList)
            {
                sw.WriteLine("album " + album);
            }


            sw.Close();
        }
示例#2
0
        private void GetPhotoAddress(string url, FileName f)
        {
            int           start;
            int           end         = 0;
            GetHtml       getHtml     = new GetHtml(url, Cookiesstr, cc);
            List <string> albumIdList = new List <string>();
            string        str         = getHtml.GetHtmlMetheod();

            //Console.WriteLine(str);
            while (str != null)
            {
                start = str.IndexOf("large:'", end);
                if (start != -1)
                {
                    try
                    {
                        end = str.IndexOf("g'", start);
                        string address = str.Substring(start + 7, (end - start - 7));
                        address += "g";
                        f.photoList.Add(address);
                    }
                    catch
                    {
                        if (end == -1)
                        {
                            end = str.IndexOf("f'", start);
                            string address = str.Substring(start + 7, (end - start - 7));
                            address += "f";
                            f.photoList.Add(address);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
示例#3
0
        private void GetidButton_Click(object sender, EventArgs e)
        {
            friendId = FriendIDBox.Text.ToString();

            int start;
            int end = 0;
            int start1;
            int end1      = 0;
            int page      = 0;
            int finalpage = 1;
            int renshu    = 0;

            do
            {
                start = 0;
                end   = 0;
                try
                {
                    string url = "http://friend.renren.com/GetFriendList.do?curpage=" + page + "&id=" + friendId;
                    string str = "";
                    #region get html source code
                    GetHtml gethtml = new GetHtml(url, Cookiesstr, cc);
                    str = gethtml.GetHtmlMetheod();
                    #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("addFriend", end);
                        if (start != -1)
                        {
                            end = str.IndexOf('"', start);
                            string number = str.Substring(start + 9, (end - start - 9));
                            try
                            {
                                a = int.Parse(number);
                                friendIdList.Add(number);
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        else
                        {
                            break;
                        }
                        #endregion
                    }


                    page++;
                    #region print out the number of friends of each page
                    if (renshu == 0)
                    {
                        renshu = friendIdList.Count;
                        Console.WriteLine("this page has " + friendIdList.Count + "friends");
                    }
                    else
                    {
                        Console.WriteLine("this page has " + (friendIdList.Count - renshu).ToString() + "friends");
                        renshu = friendIdList.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 = "I://lcj//" + friendId + "Id.txt";
            StreamWriter sw         = new StreamWriter(outPutPath, true);
            foreach (string id in friendIdList)
            {
                AllFriendIdBox.Text += id.ToString() + "\r\n";
                sw.WriteLine(id);
            }
            sw.Close();
            #endregion
            Console.WriteLine("Your friend has " + friendIdList.Count + " friends");
        }