Exemplo n.º 1
0
        private void SaveTabir(string WordName, string TabirUrl)
        {
            ReqUtils Reqs = new ReqUtils();

            TabirUrl = TabirUrl.Replace("\" target=\"_blank", "");
            string Result   = Reqs.GetHTML(TabirUrl, System.Text.Encoding.UTF8);
            string _pattern = @" class=""contentpaneopen_text"">\s*(.*?)</div>";
            Regex  r        = new Regex(_pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            Match  m        = r.Match(Result);

            if (m.Success)
            {
                string Meaning = m.Groups[1].Captures[0].ToString();
                Meaning = Reqs.RemoveTags(Meaning);

                TabirDataContext            dc        = new TabirDataContext();
                Parsetv91._1.Code.DAL.Tabir NewRecord = new Code.DAL.Tabir();
                dc.Tabirs.InsertOnSubmit(NewRecord);
                NewRecord.WordName = WordName;
                NewRecord.Meaning  = Meaning;
                NewRecord.ID       = MainCounter.ToString();
                MainCounter++;
                dc.SubmitChanges();
            }
        }
Exemplo n.º 2
0
        protected void btnakairan_Click(object sender, EventArgs e)
        {
            int      Counter = 0;
            ReqUtils Reqs    = new ReqUtils();


            string Params = "-a.html,-b.html,-p.html,-t.html,-se.html,-j.html,-ch.html,-h.html,-kh.html,-d.html-zal.html,-r.html,-z.html,24263.html,-sin.html,-shin.html,-sad.html,-zad.html,-ta.html,-za.html,-eyn.html,-ghein.html,-f.html-gh.html,-k.html,-g.html,-l.html,-m.html,-n.html,-v.html,-he.html,-ye.html";

            string[] ParamsArray = Params.Split(',');
            for (int i = 0; i < ParamsArray.Length; i++)
            {
                string CurUrl = "";
                if (ParamsArray[i] == "")
                {
                    CurUrl = "http://tabirkhab.akairan.com/sleep/sleep/";
                }
                else
                {
                    CurUrl = "http://tabirkhab.akairan.com/sleep/sleep/jadval" + ParamsArray[i];
                }
                string Result   = Reqs.GetHTML(CurUrl, System.Text.Encoding.UTF8);
                string _pattern = @"<td class=""buttmtbl""><a href=""(.*?)"">(.*?)</a></td>";
                Regex  r        = new Regex(_pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                Match  m        = r.Match(Result);
                while (m.Success)
                {
                    Title = m.Groups[2].Captures[0].ToString();
                    Title = Tools.PersianTextCorrection(Title);
                    if (GetTabirCount(Title) == 0)
                    {
                        string TabirUrl = m.Groups[1].Captures[0].ToString();
                        SaveTabir(Title, TabirUrl);
                        Counter++;
                    }
                    m = m.NextMatch();
                }
                lblMessage.Text = Counter + " Tabirs added";
            }
        }
Exemplo n.º 3
0
    void ListNews(int privateSiteCode, string privateNewsUrl, string privateNewsTitle, string privateREDetail, string privateREImage, string privateREVideo, int Count, string LinkDomainName, int EncodingTypeCode)
    {
        ReqUtils gn = new ReqUtils();
        string   NewsContentHtml = "";
        string   FullStory       = "";
        string   ImageSource     = "";
        string   VideoSource     = "";
        string   TextTitle       = "";
        string   NewsCode        = "";

        System.Text.Encoding enc = System.Text.Encoding.UTF8;
        if (EncodingTypeCode != 1)
        {
            IBaseBOL <DataTable> BolHardCode = new BOLHardCode();
            BolHardCode.QueryObjName = "HCEncodingTypes";
            DataTable dt = BolHardCode.GetDetails(EncodingTypeCode);
            enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString());
        }
        privateNewsUrl = privateNewsUrl.Replace("//", "/");
        privateNewsUrl = privateNewsUrl.Replace("http:/", "http://");
        privateNewsUrl = privateNewsUrl.Replace("https:/", "https://");
        if (privateREDetail.Length > 0)
        {
            NewsContentHtml = gn.GetHTML(privateNewsUrl, enc);

            if (privateREDetail != null && privateREDetail != "")
            {
                FullStory = gn.GetREGroup(NewsContentHtml, privateREDetail, "CONTENT");
            }
            if (privateREImage != null && privateREImage != "")
            {
                ImageSource = gn.GetREGroup(NewsContentHtml, privateREImage, "IMAGE");
            }
            if (privateREVideo != null && privateREVideo != "")
            {
                VideoSource = gn.GetREGroup(NewsContentHtml, privateREVideo, "VIDEO");
            }

            if (!ImageSource.StartsWith("http://") && !ImageSource.StartsWith("https://") && ImageSource != "")
            {
                ImageSource = LinkDomainName + ImageSource;
            }


            if (!VideoSource.StartsWith("http://") && VideoSource != "")
            {
                VideoSource = LinkDomainName + VideoSource;
            }


            FullStory = gn.RemoveTags(FullStory, "br");
            FullStory = FullStory.Replace("'", "");
            FullStory = FullStory.Replace("\"", "");
            FullStory = FullStory.Replace("\r", "");
            FullStory = FullStory.Replace("\t", "");
            FullStory = FullStory.Replace("&nbsp;", "");

            ImageSource = ImageSource.Replace("[", "%5B");
            ImageSource = ImageSource.Replace("]", "%5D");

            VideoSource = VideoSource.Replace("[", "%5B");
            VideoSource = VideoSource.Replace("]", "%5D");


            if (ImageSource != "") //Save News File
            {
                try
                {
                    int       SlashPos = ImageSource.LastIndexOf("/");
                    string    FileName = ImageSource.Substring(SlashPos + 1, ImageSource.Length - SlashPos - 1);
                    WebClient WebCl    = new WebClient();
                    string    FName    = Server.MapPath("~/Files/News/" + Tools.GetRandomFileName(FileName));
                    //WebCl.DownloadFile(ImageSource, FName);
                }
                catch
                {
                }
            }
        }
        TextTitle = gn.RemoveTags(privateNewsTitle);

        string ImageTag = "";

        if (ImageSource != "")
        {
            ImageSource = "<img src=\"" + ImageSource + "\">";
        }
        string outStr = string.Format("<table border=\"1\" class=\"cNews\" dir=\"rtl\" width=\"100%\" ><tr><td>{0}</td><td >{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr></table>", Count, TextTitle, FullStory.Length, ImageSource, VideoSource, privateNewsUrl);

        Response.Write(outStr);
        Response.Flush();


        gn.Dispose();
    }
Exemplo n.º 4
0
    public void GetSingleSite(int privateSiteCode, int privateLimitCount)
    {
        int    Count           = 1;
        string NewsTitle       = "";
        string HtmlContent     = "";
        string EditedNewsTitle = "";
        string NewsTextTitle   = "";

        ReqUtils gn;

        string SelectStatement = "";

        BOLResourseSiteCats ResourceSiteCatsBOL = new BOLResourseSiteCats(1);
        vResourseSiteCats   SingleSite          = ResourceSiteCatsBOL.GetSingleSite(privateSiteCode);

        int    SiteCode         = SingleSite.Code;
        string SiteName         = SingleSite.Name;
        string SiteUrl          = SingleSite.Url;
        int?   EncodingTypeCode = SingleSite.HCEncodingTypeCode;
        string BaseURL          = SingleSite.BaseURL;

        string RELink   = SingleSite.RELink;
        string REDetail = SingleSite.REDetail;
        string REImage  = SingleSite.REImage;
        string REVideo  = SingleSite.REVideo;

        ArrayList NewList = new ArrayList();

        gn = new ReqUtils();
        System.Text.Encoding enc = System.Text.Encoding.UTF8;
        if (EncodingTypeCode != 1)
        {
            IBaseBOL <DataTable> BolHardCode = new BOLHardCode();
            BolHardCode.QueryObjName = "HCEncodingTypes";
            DataTable dt = BolHardCode.GetDetails((int)EncodingTypeCode);
            enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString());
        }

        int    LastSlash = SiteUrl.LastIndexOf("/");
        string LinkDomainName;

        if (BaseURL != null && BaseURL != "")
        {
            LinkDomainName = BaseURL;
        }
        else
        {
            LinkDomainName = SiteUrl.Substring(0, LastSlash + 1);
        }
        if (!(bool)SingleSite.RssIsActive)
        {
            HtmlContent = gn.GetHTML(SiteUrl, enc);
            NewList     = gn.ExtractNewsLinks(HtmlContent, RELink, LinkDomainName);
        }
        else
        {
            NewList = GetNewsList(SingleSite.RssUrl);
        }

        IEnumerator NewENum = NewList.GetEnumerator();

        gn = new ReqUtils();
        while (NewENum.MoveNext())
        {
            NewsTitle     = NewENum.Current.ToString();
            NewsTextTitle = gn.RemoveTags(NewsTitle);
            BOLNews NewsBOl = new BOLNews();

            if (!NewsBOl.CheckNewsExists(NewsTextTitle, SiteCode))
            {
                string RealLink = gn.ExtractLink(NewsTitle);
                string outStr   = "";
                //outStr = string.Format("<table width=100% ><tr><td class=\"cNews\">{1}</td><td>{0}</td></tr></table>", Count, NewsTitle);
                //Response.Write(outStr);
                //Response.Flush();
                ListNews(SiteCode, RealLink, NewsTitle, REDetail, REImage, REVideo, Count, LinkDomainName, (int)EncodingTypeCode);
            }

            Count++;
            if (privateLimitCount != 0)
            {
                if (privateLimitCount == Count)
                {
                    break;
                }
            }
        }
    }