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) ;iparseInt(numEnd1.value);i++) { for(j=parseInt(numStart2.value);jparseInt(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) // 調(diào)用完畢 { 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] = "全部社區(qū)";