下面这个正则式解析A标记的,ftp://games:[email protected] 有下载Regex re = new Regex(@"<[a|img|script|link]\s+[href|src]+=([""'])(?<url>[^'"">]+)\1\s*>(\s*(?<name>[^-\s|(<img\S\s</)]*)\s*-)?\s*(?<song>[^<]+)</", RegexOptions.IgnoreCase | RegexOptions.Singleline); MatchCollection mc = re.Matches(PageStr); foreach (Match m in mc) { if (m.Groups["name"].Value != "") this.strFileList.AppendText(m.Groups["name"].Value); else if (m.Groups["name"].Captures.Count > 0)
没经过严格测试,但能符合你这个例子的要求。
MatchCollection mc = re.Matches(PageStr);
foreach (Match m in mc)
{
if (m.Groups["name"].Value != "")
this.strFileList.AppendText(m.Groups["name"].Value);
else if (m.Groups["name"].Captures.Count > 0)
this.strFileList.AppendText("未知");
else
strFileList.AppendText("文件名");
strFileList.AppendText("\t");
strFileList.AppendText(m.Groups["song"].Value);
strFileList.AppendText("\t");
strFileList.AppendText(m.Groups["url"].Value);
UrlList.Append(m.Groups["url"].Value);
strFileList.AppendText("\n");
}
strFileList.AppendText("遍历URL树:\n");
UrlList.MoveFrist();
string url=string.Empty;
while(!UrlList.IsEof())
{
url=UrlList.GetCurrentValue().ToString();
//strFileList.AppendText(UrlList.GetCurrentValue()+"\n");
//GetDirPath(url);
//strFileList.AppendText();
if(url.IndexOf("/")==-1)
{
url=this.UrlAddress.Text+"/"+url;
}
if(url.StartsWith("/"))
{
url="http://"+Core.GetUrlRootPath(this.UrlAddress.Text)+"/"+url;
}
if(url.StartsWith("."))
{
url=Core.GetAndNormailizePath(url);
}
ftp密码不对啊,进不去,能不能发到我邮箱里
[email protected],谢谢