读以记事本中的网址,记事本里中有多个网址,每个一行,然后使用AJAX循环请求随机出来的部分不重复的网址
set srmObj = server.CreateObject("adodb.stream")
srmObj.type=1
srmObj.mode=3
srmObj.open
srmObj.Position=0
srmObj.LoadFromFile(Server.MapPath("url.txt"))'读取记事本中的内容
srmObj.Position = 0
srmObj.type=2
srmObj.charset="utf-8"
content=srmObj.readtext()
Set srmObj=Nothing
url_arr =split(content,vbCrLf)'使用记事本中的换行符作为分隔符打散成数组
For I = Lbound(url_arr) to Ubound(url_arr)-1
url_str=url_str&"'"&url_arr(I)&"',"'组装'1','2','3',这样的字符串
Next
url_str=left(url_str,Len(url_str)-1)'去掉最右边的那个字符,这里即逗号
script代码如下,需要先调用jquery.js文件
function getRandomArrayElements(arr, count) {
var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
while (i-- > min) {
index = Math.floor((i + 1) * Math.random());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return shuffled.slice(min);
}
var url_arr = [<%=url_str%>];
var rand_url_arr = getRandomArrayElements(url_arr,Math.round(url_arr.length/3));
for(var j = 0; j < rand_url_arr.length; j++){
$.ajax({
async:false,
cache: false,
timeout: 5000,
type: 'GET',
url: rand_url_arr[j]
});
}
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%'读以记事本中的网址,记事本里中有多个网址,每个一行,然后使用AJAX循环请求随机出来的部分不重复的网址set srmObj = server.CreateObject("adodb.stream")srmObj.type=1srmObj.mode=3srmObj.opensrmObj.Position=0srmObj.LoadFromFile(Server.MapPath("url.txt"))'读取记事本中的内容srmObj.Position = 0srmObj.type=2srmObj.charset="utf-8"content=srmObj.readtext()Set srmObj=Nothingurl_arr =split(content,vbCrLf)'使用记事本中的换行符作为分隔符打散成数组For I = Lbound(url_arr) to Ubound(url_arr)-1 url_str=url_str&"'"&url_arr(I)&"',"'组装'1','2','3',这样的字符串Nexturl_str=left(url_str,Len(url_str)-1)'去掉最右边的那个字符,这里即逗号%><script src="js/jquery.js"></script><script type="text/javascript">function getRandomArrayElements(arr, count) { var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index; while (i-- > min) { index = Math.floor((i + 1) * Math.random()); temp = shuffled[index]; shuffled[index] = shuffled[i]; shuffled[i] = temp; } return shuffled.slice(min);}var url_arr = [<%=url_str%>];var rand_url_arr = getRandomArrayElements(url_arr,Math.round(url_arr.length/3));for(var j = 0; j < rand_url_arr.length; j++){$.ajax({ async:false, cache: false, timeout: 5000, type: 'GET', url: rand_url_arr[j]});}</script>