给你一段源代码:--------------------------------------------------------------------------------
static clsSaveWebPage()
{
// Setup regular expressions for link parsing
_hrefRegEx = new Regex("a.*href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
_imgSrcRegEx = new Regex("img.*src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
}public static string [] FindImgSrc(string html)
{
// Get the matches collection
MatchCollection c = _imgSrcRegEx.Matches(html);
// Create an array of strings from the match collection
int i = 0;
string [] links = new string[c.Count];
foreach(Match match in c) links[i++] = match.Groups[1].ToString(); return links;
}不全,但你要的正则表达式和思路有!
static clsSaveWebPage()
{
// Setup regular expressions for link parsing
_hrefRegEx = new Regex("a.*href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
_imgSrcRegEx = new Regex("img.*src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
}public static string [] FindImgSrc(string html)
{
// Get the matches collection
MatchCollection c = _imgSrcRegEx.Matches(html);
// Create an array of strings from the match collection
int i = 0;
string [] links = new string[c.Count];
foreach(Match match in c) links[i++] = match.Groups[1].ToString(); return links;
}不全,但你要的正则表达式和思路有!
解决方案 »
- 泛型,泛型类,泛型接口 搞晕了。
- 简单那的换行问题....请大家帮忙...!~
- asp.net 2.0 中的一个小问题
- 我的网站验证控件不好用为什么?先前好用了的,asp.net 1.1
- 菜鸟问题关于ItemDataBound
- 谁能给我一个实现在线office的控件啊?
- 送分题:怎么隐藏DataGrid中的“删除”按钮列?
- asp 关于弹窗值得回传!!急~~
- 动态为UpdatePanel添加AsyncPostBackTrigger的问题
- (急)寻ASP.NET(C#)客户端二维码生成打印方法
- 100分求如下正则表达式!分不够再加!(一、网页中的链接)
- 开100分,来讨论在线编辑器的链接抓取问题
html你可以用HttpWebRequest抓取网页代码,赋给string html即可!