Esempio n. 1
0
        public static void timerGetArticle_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            Link_To_Get rs = GetOneLinkToGet();


            WebDownloader wd = new WebDownloader();
            Encoding      ec = Encoding.GetEncoding("UTF-8");
            //string strContent = wd.GetPageByHttpWebRequest(rs.strSiteUrl, ec, "");
            //GetSiteLinks(rs, strContent);

            ContentGatherRule cgr = new ContentGatherRule();
            bool   bFind          = false;
            string strUrlRuleFind = "";

            foreach (string strTemp in m_dicSiteRules.Keys)
            {
                string strUrlRule = strTemp;
                strUrlRule = strUrlRule.Replace(".", "\\.");
                strUrlRule = strUrlRule.Replace("*", ".*?");
                MatchCollection matchs = Regex.Matches(rs.strSiteUrl, strUrlRule, RegexOptions.Singleline);
                if (matchs.Count > 0)
                {
                    bFind          = true;
                    strUrlRuleFind = strTemp;
                    break;
                }
            }
            //这里要向服务器报告已经处理过,数据表需要增加字段
            if (!bFind)
            {
                return;
            }
            else
            {
                cgr.strArticleContentCssPath = m_dicSiteRules[strUrlRuleFind];
            }



            string strArticle = wd.GetPageByHttpWebRequest(rs.strSiteUrl, ec, "");



            strArticle = GetPageContent(cgr.strArticleContentCssPath, strArticle);
            string strUpdateContentUrl = strApiUrl + "/index.php/api/index/update_article_content";


            Encoding encoding = Encoding.GetEncoding("utf-8");

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            strArticle = System.Web.HttpUtility.HtmlDecode(strArticle);
            parameters.Add("id", rs.nID.ToString());
            parameters.Add("content", strArticle);
            //parameters.Add("password", password);

            HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(strUpdateContentUrl, parameters, null, null, encoding, null);

            Console.WriteLine("timerGetArticle_Elapsed");
        }
Esempio n. 2
0
        public static void timerGetLinks_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            RssSource     rs         = GetOneTask();
            WebDownloader wd         = new WebDownloader();
            Encoding      ec         = Encoding.GetEncoding("UTF-8");
            string        strContent = wd.GetPageByHttpWebRequest(rs.strSiteUrl, ec, "");

            GetSiteLinks(rs, strContent);

            Console.WriteLine("timerGetLinks_Elapsed");
        }