var xmlURL=new String(); var headURL ="http://community.csdn.net/Expert/topic/"; var tailURL =".xml?temp=";
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); var stream = new ActiveXObject("ADODB.Stream"); var fso = new ActiveXObject("Scripting.FileSystemObject")
//定义本文件绝对路径 var thisFileDir =getthisFileDir(); //定义本文件名 var thisFileName = LastOne(thisFileDir,"//"); //定义本文件夹路径 var thisFileFolder = getFolderDir(thisFileDir); InitBigClass(); InitSmallClass(); var xmlID; var xmlFolder = setFolder("xml"); function gogogo() { //主程序 wormClick.innerText ="正在爬..."; //window.resizeTo(100,200); //window.scrollTo(10,20); //window.moveTo(window.screen.availWidth-200,window.screen.availHeight-250) for(i=parseInt(numStart1.value) ;i<parseInt(numEnd1.value);i++) { for(j=parseInt(numStart2.value);j<parseInt(numEnd2.value);j++) { xmlURL = headURL + i + "/" + j + tailURL + Math.random().toString().substr(1,8); try { saveToFile(xmlURL,smallclassid.value); xmlID = j; } catch(e) { } }
function saveToFile(URL,classID) { xmlhttp.Open("GET",URL, false); try { xmlhttp.Send(); var result = xmlhttp.status; } catch(e) { return(false); } if (xmlhttp.readyState == 4) // 调用完毕 { if(result==200) { var tempXML=xmlhttp.responseBody; stream.type=1; stream.Open() ; stream.Write(tempXML); stream.SaveToFile(xmlFolder + xmlID + ".xml") stream.Close(); } } }
function setFolder(str) { var folder = thisFileFolder + str; if(!fso.FolderExists( folder)) { fso.CreateFolder(folder) } return(folder + "//") }
function getthisFileDir() {//得到本文件完全路径 var temp = window.location.href; temp = temp.substr(8); temp = unescape(temp); temp = temp.replace(/[//]/ig,"//") return(temp); } function LastOne(Str,splitStr) {//输入字符和分隔符,得到最后一部分 var Arr=Str.split(splitStr) return(Arr[Arr.length-1]); } function getFolderDir(fullDir) {//输入得到全路径,得到文件夹路径 var s=LastOne(fullDir,"//"); return(fullDir.substr(0,fullDir.length-s.length)); } function InitBigClass() { bigclass = new Array();
bigclass[0] = new Array(); bigclass[0][0] = "0"; bigclass[0][1] = "全部社区";