|
function test() {
str = wyfw("http://www.baidu.com",2,3,4,5)
return str;}
//=========================
//wyfw(url,2,3,4,5)
/*
wyfw(url,method,data,Referer,fhlx)
1、url=完整网址
2、method=提交动作,默认为"GET"
3、data=提交内容"POST"专用
4、Referer=来源地址
5、fhlx=返回类型,默认为文本
注:全局变量AllResponseHeaders将储存返回的全部协议头
*/
obj = new ActiveXObject("WinHttp.WinHttpRequest.5.1")
function wyfw(url,method,data,Referer,fhlx) {
if (method===2){obj.Open("GET",url,false);}
else{obj.Open("POST",url,false);}
obj.SetRequestHeader("Accept", "*/*");
obj.SetRequestHeader("Accept-Language", "zh-cn");
obj.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
obj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (Referer===4){Referer=url;}
obj.SetRequestHeader("Referer",Referer);//设置来源
t = 5000
obj.SetTimeouts(t,t,t,t);//设置超时
if (data===3){obj.Send();}
else{obj.Send(data);}
AllResponseHeaders = obj.GetAllResponseHeaders//返回协议头
if (fhlx===5){text = obj.ResponseText();}
else{text = obj.ResponseBody();}
return text;}
//=========================
|
评分
-
查看全部评分
|