Example #1
0
        public static void SayThanks(string url, string cookie)
        {
            string host = new Uri(url).Host;
            var    id   = ParseUrl(url).Get("id");

            string[] returns = WebOperating.PostMode(string.Format("{0}://{1}/thanks.php", new Uri(url).Scheme, host), url, "id=" + id, cookie, host);
            if (returns[0] == "200")
            {
                Console.WriteLine("说谢谢成功");
                WriteLog("说谢谢成功:" + url);
            }
            else
            {
                Console.WriteLine(string.Format("{0}:{1}", returns[0], returns[1]));
                WriteLog("说谢谢失败:" + string.Format("{0}:{1}", returns[0], returns[1]));
            }
        }
Example #2
0
        public static void GetAllItems(string url, string cookie)
        {
            string host = new Uri(url).Host;

            do
            {
                string html = WebOperating.GetMode(url, host, cookie, host);
                var    doc  = new HtmlDocument();
                doc.LoadHtml(html);
                var root         = doc.DocumentNode;
                var torrentnodes = root.SelectNodes("//table[@class='torrentname']");
                foreach (var torrent in torrentnodes)
                {
                    if (!IsRunning)
                    {
                        break;
                    }
                    var torrentUrl = torrent.SelectSingleNode(torrent.XPath + "/tr/td[1]/a").GetAttributeValue("href", "");
                    torrentUrl = HttpUtility.HtmlDecode(torrentUrl);
                    WriteLog("开始处理:" + torrentUrl);
                    Console.WriteLine(torrentUrl);
                    GetDetail(new Uri(new Uri(url), torrentUrl).ToString(), cookie);
                    Thread.Sleep(10000);
                }
                var nextPage = root.SelectSingleNode("//b[@title='Alt+Pagedown']");
                if (nextPage != null)
                {
                    var href = nextPage.ParentNode.GetAttributeValue("href", "");
                    if (href != "")
                    {
                        href = HttpUtility.HtmlDecode(href);
                        url  = new Uri(new Uri(url), href).ToString();
                    }
                    else
                    {
                        url = string.Empty;
                    }
                }
                else
                {
                    url = string.Empty;
                }
                Console.WriteLine(url);
                WriteLog("翻到下一页:" + url);
            } while (IsRunning && url != string.Empty);
        }
Example #3
0
        public static void GetDetail(string url, string cookie)
        {
            string host = new Uri(url).Host;
            string html = WebOperating.GetMode(url, host, cookie, host);
            var    doc  = new HtmlDocument();

            doc.LoadHtml(html);
            var root         = doc.DocumentNode;
            var thanksButton = root.SelectSingleNode("//input[@id='saythanks']");

            if (thanksButton.GetAttributeValue("disabled", "") != "")
            {
                Console.WriteLine("已经说过谢谢");
                WriteLog("已经说过谢谢:" + url);
            }
            else
            {
                Console.WriteLine("没有说过谢谢");
                SayThanks(url, cookie);
            }
        }