C#网页采集

  /// <summary>
/// 返回提取数组
/// </summary>
/// <param name="rex">正则</param>
/// <param name="urlValue">字符串</param>
/// <returns></returns>
private string[] rexID(string rex, string urlValue)
{
ArrayList al = new ArrayList();
string strRegex = rex;
Regex r = new Regex(strRegex, RegexOptions.IgnoreCase);
MatchCollection m = r.Matches(urlValue);
for (int i = ; i <= m.Count - ; i++)
{
bool rep = false;
string strNew = m[i].ToString();
string zregexStr = rex;
Regex l = new Regex(zregexStr, RegexOptions.None);
Match mc = l.Match(strNew);
string dataStr = mc.Groups["key"].Value;
// 过滤重复的URL
foreach (string str in al)
{
if (strNew == str)
{
rep = true;
break;
}
}
if (!rep)
{
al.Add(dataStr);
}
}
string[] shuzu = new string[al.Count];
int id = ;
foreach (string item in al)
{
shuzu[id] = item;
id++;
}
return shuzu;
}
上一篇:Android开发怎么让自己的APP UI漂亮、大方(配色篇二)


下一篇:C# 生成中间含有LOGO的二维码