<a target="_blank" title="杯具的人生" style="" href="http://www.ifeng.cn/u/20100227/16/9e9d906c-19d3-4006-8115-a31023a3ad4e.html">真的是民工荒啊,导致工厂招不到人</a>
</td>
<td>
20
</td>
<td>
<a target="_blank" href="http://www.ifeng.cn/pingyou">
pingyou
</a>
<br>
<span class="gray">02-27 16:32</span>
</td>
<td>
0
</td>
以上内容,重复许多次,求能抓取,红色标出为零时的URL,在本例中为 http://www.sina.cn/u/20100227/16/9e9d906c-19d3-4006-8115-a31023a3ad4e.html在此先谢过,不能发200分的帖子,但会加分.. ..
http://www.ifeng.cn/u/20100227/16/9e9d906c-19d3-4006-8115-a31023a3ad4e.html
地址还是看不到
----------------
得到 <td>
0
</td>
这个红色”0“ 值的url吗? 这个地址来自与外网?
非要用正则吗? 用js 不是挺好的吗?
元宵节 节日快乐
MatchCollection mc = reg.Matches(yourStr);
foreach(Match m in mc)
{
richTextBox2.Text += m.Groups["url"].Value + "\n";
}
您的我试了,不行,好吧,我坦白,真正的链接其实是 http://forum.csdn.net/SList/FreeZone// 这个
我想要抓取0回复帖子的URL,请您帮下我吧~
你吖的笨到家了!API当然会提供这个http://blog.csdn.net/yizhu2000/archive/2008/03/28/2226087.aspx当你解析的时候人家都吖的把沙发给拿下了!
private string GetHtmlCode(string url, Encoding encoding)
{
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream resStream = response.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, encoding);
string html = (sr.ReadToEnd());
resStream.Close();
sr.Close();
return html;
}
//解析
string html = GetHtmlCode("http://forum.csdn.net/PointForum/Forum/TopicList.aspx?Alias=FreeZone&ListType=UnClosedList&page=3", Encoding.UTF8);
Regex reg = new Regex(@"(?isn)<a((?!href=).)*href=""(?<url>[^""]*)""[^>]*>(((?!<td\b).)*<td>){3}\s*\b0\b");
MatchCollection mc = reg.Matches(html);
if (mc.Count == 0)
{
richTextBox2.Text = "当前页没有零回复帖子!";
}
else
{
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups["url"].Value + "\n";
}
}
//输出
http://topic.csdn.net/u/20100228/09/229f7867-41a9-41fc-bb23-a8183dc7c540.html
I LOVE YOU
http://topic.csdn.net/u/20100228/20/9f78469a-d541-418e-829d-b24626b45721.html这个帖子,您也回下吧,我好结贴~ 谢谢 :-),发光``你别紧张``你也有分. ...