コード例 #1
0
ファイル: AnalysisPage.cs プロジェクト: yijiahe/peidiansuo
 public static string[] AnalysisMarkList(string content, WebPageMark mark, string id)
 {
     string[] markList = content.Split(new string[] { "</" + mark.ToString() + ">" }, System.StringSplitOptions.RemoveEmptyEntries);
     if (markList.Length == 0)
     {
         return(new string[0]);
     }
     string[] ml = new string[markList.Length];
     if (id != null && id.Length > 0)
     {
         if (markList.Length > 1)
         {
             int count = 0;
             for (int i = 0; i < ml.Length; i++)
             {
                 if (markList[i].Contains('"' + id + '"'))
                 {
                     ml[count] = markList[i];
                     count    += 1;
                 }
             }
             string[] str = new string[count];
             for (int i = 0; i < count; i++)
             {
                 str[i] = ml[i];
             }
             return(str);
         }
         else
         {
             if (markList[0].Contains('"' + id + '"'))
             {
                 ml = markList;
             }
             else
             {
                 ml[0] = "";
             }
         }
     }
     else
     {
         ml = markList;
     }
     return(ml);
 }
コード例 #2
0
ファイル: AnalysisPage.cs プロジェクト: yijiahe/peidiansuo
    public static string AnalysisOneLable(string pagecontent, WebPageMark webpagemark, string id)
    {
        if (pagecontent == null && pagecontent.Length == 0)
        {
            return(null);
        }
        if (!pagecontent.Contains(webpagemark.ToString()))
        {
            return(null);
        }

        string str = "";

        string[] strs = pagecontent.Split(new string[] { "<" + webpagemark.ToString() }, System.StringSplitOptions.RemoveEmptyEntries);

        for (int i = 0; i < strs.Length; i++)
        {
            if (strs[i].Contains('"' + id + '"'))
            {
                string[] str_1 = strs[i].Split(new string[] { "</" + webpagemark.ToString() }, System.StringSplitOptions.RemoveEmptyEntries);
                if (webpagemark == WebPageMark.td)
                {
                    string[] str_2 = str_1[0].Split(new string[] { ">" }, System.StringSplitOptions.RemoveEmptyEntries);
                    if (str_2.Length > 1)
                    {
                        str = str_2[1];
                    }
                    else
                    {
                        str = str_2[0];
                    }
                }
                else
                {
                    str = str_1[0];
                }
            }
        }
        return(str);
    }