asp中有什么方法可以代替php的fsockopen函数

歪歪 2007-01-13 02:00:08
主要是伪装http头的问题,郁闷的,我用xmlhttp.setRequestHeader伪装没调试成功

function HttpPostConnect($host,$path,$fieldArray=array())
{
$port=80;
if(sizeof($fieldArray) > 0) {
$body = _encodeFields( $fieldArray );
}else{
$body = "";
}
$len = strlen( $body );

$request=($body ? "POST" : "GET")." $path HTTP/1.0\r\n".
"Host: $host\r\n".
"Accept: */*\r\n".
"Accept-Language: en-us,zh-cn;q=0.5\r\n".
($body ? "Content-type: application/x-www-form-urlencoded\r\n" : "").
"Proxy-Connection: Keep-Alive\r\n".
($len ? "content-length: $len\r\n" : "").
"\r\n".
($body ? "$body" : "");
$fp = fsockopen( "$host", $port, $errno, $errdesc, 30 );
if(!$fp) return false;
fputs($fp,$request);
while(trim(fgets($fp,1024)) != "");
return $fp;
}
...全文
420 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sib2000 2007-01-14
  • 打赏
  • 举报
回复
自己定议一个function
hongwei1230 2007-01-14
  • 打赏
  • 举报
回复
哪位大哥能不能告诉我怎么开始学习ASP技术
歪歪 2007-01-13
  • 打赏
  • 举报
回复
多谢楼上的朋友,呵呵
deknight 2007-01-13
  • 打赏
  • 举报
回复
我觉得写个socket的动态库更好一些,在asp调用
歪歪 2007-01-13
  • 打赏
  • 举报
回复
mbr = chr(13)

:)
歪歪 2007-01-13
  • 打赏
  • 举报
回复
function HttpPostConnect(host,path,fieldArray)
port=80
if IsObject(fieldArray) then
body = encodeFields(fieldArray )
else
body = ""
end if
xlen = len(body)
if xlen > 1 then
hMot = "POST"
hx = "Content-type: application/x-www-form-urlencoded" & mbr
lx = "content-length: " & xlen & chr(10) & mbr & body
else
hMot = "GET"
hx = ""
lx = "" & mbr & body
end if
hBod = hMot & " " & path & " HTTP/1.0" & mbr & "Host: " & right(host,len(host)-7) & mbr & "Accept: */*" & mbr
hBod = hBod & "Accept-Language: en-us,zh-cn;q=0.5" & mbr & hx & "Proxy-Connection: Keep-Alive" & mbr & lx

set Http=Server.createobject("MSXML2.XMLHTTP")
Http.Open hMot,host & path,False
Http.send(hBod)
Result = Http.Responsetext
HttpPostConnect = Result
end function
歪歪 2007-01-13
  • 打赏
  • 举报
回复
提示
Error: Can not access from Browser
cpp2017 2007-01-13
  • 打赏
  • 举报
回复
asp没有socket函数, xmlhttp.setRequestHeader伪装不成功,说来听听有什么问题?
歪歪 2007-01-13
  • 打赏
  • 举报
回复
自己先顶

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧