JS获取网站状态码,若网站存在,写入TXT文件,适用于IE。
<script>
//写文件
function writeFile(filename,filecontent){
var fso, f, s ;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,8,true);
f.WriteLine(filecontent);
f.Close();
}
//判断网站是否能打开
function http_go(URL)
{
var http_c= new ActiveXObject("microsoft.xmlhttp");
http_c.Open("GET",URL,false);
try
{
http_c.Send();
}
catch(e){}
finally{
var result = http_c.responseText;
if(result)
{
if(http_c.Status==200)
return(true);
else
return(false);
}
else
return(false);
}
}
var q = ['bj','sh','sz','gz','tj','hz','nj'];
var c = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'];
for(var x=0;x<q.length;x++)
for(var i=0;i<c.length;i++)
for(var j=0;j<c.length;j++)
for(var k=0;k<c.length;k++)
{
var domain_m =q[x]+c[i]+c[j]+c[k]+'.com';
var domain_m1 ='http://'+domain_m;
var domain_m2 ='http://www'+domain_m;
if(http_go(domain_m1)||http_go(domain_m2)){
writeFile('D:/WORK/domain/domain_qc.txt',domain_m);
}
}
</script>