| 发表于:2007-11-18 07:34:15 楼主 |
using system; using system.collections.generic; using system.text; using system.data; using system.data.sqlclient; using system.text.regularexpressions; using system.net; namespace mygrab { class china { static void main(string[] args) { webclient mywebclient = new webclient(); mywebclient.credentials = credentialcache.defaultcredentials; byte[] mybyte = mywebclient.downloaddata("http://61.135.173.47:6666/outline.wct?page=1&result=96399&selectid=8&channelid=4832&recid=0"); string mystring = encoding.default.getstring(mybyte); regex re = new regex(@" <td\scolspan=""2""> <blockquote> [\s\s]*?""(? <web_url> [\s\s]*?)"""); matchcollection mc = re.matches(mystring); int intnumber = 0; foreach (match m in mc) { intnumber++; console.writeline(intnumber ); console.writeline(m.groups["web_url"] ); } console.writeline("> > > > > "); console.readline(); } } } 这样居然不到数据……………………???搞不懂!,我的正则表达式没有问题啊! 于是我把那个网址的源代码复制过来!然后把程序抓取入口改称本地路径也就是(localhost) 数据就出来了! 搞不懂! |
|
|
|
|