| 发表于:2007-08-21 18:45:33 楼主 |
private void button1_click(object sender, eventargs e) { string str = " "; string filetxt = " "; int count = 0; filetxt = this.filetxt.text; if (filetxt== " ") { filetxt = "html.txt "; } int begindex = 0; int endindex = 0; string num = " "; byte[] buf = new byte[38192000]; num = this.tb1.text.tostring(); string keyword = this.keyword.text; string kwend = this.kwend.text; int index = num.indexof(keyword); int indexend = num.indexof(kwend); int start=0; index= index + keyword.length; begindex = convert.toint32(num.substring(index, indexend-index)); endindex = convert.toint32(this.tb2.text); for (; begindex <= endindex; begindex++) { string page = tb1.text.substring(0, index - 1) + begindex + tb1.text.substring(indexend); httpwebrequest request = (httpwebrequest) webrequest.create(page); httpwebresponse response = (httpwebresponse) request.getresponse(); stream resstream = response.getresponsestream(); count = resstream.read(buf, 0, buf.length); str = str + encoding.default.getstring(buf, 0, count); resstream.close(); } this.loadtotext(str, filetxt); } 当点击抓取按钮时,程序根网页url(123.asp?id=456&page=1)里 id的范围抓取网页html源码,所有的网页能全部抓到了,但都不全,是 byte[]错了吗?高手指教! |
|
|
|
|