<?php
/*****************函数部分**************************/
/*获取指定网页的内容
$url为网页地址
*/
function getcontent($url){
if($open=file($url)){
$count=count($open);
for($i=0;$i<$count;$i++)
{
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
?>
<?php
/***********************程序部分**************************/
$url="http://www.url.com/judge.jsp?username=admin&password=admin888";
getcontent($url);//第一处
$url="http://www.url.com/manage.jsp";
$gethtml=getcontet($url);
echo $gethtml;
?>
不就可以完成楼主功能吗?
/*****************函数部分**************************/
/*获取指定网页的内容
$url为网页地址
*/
function getcontent($url){
if($open=file($url)){
$count=count($open);
for($i=0;$i<$count;$i++)
{
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
?>
<?php
/***********************程序部分**************************/
$url="http://www.url.com/judge.jsp?username=admin&password=admin888";
getcontent($url);//第一处
$url="http://www.url.com/manage.jsp";
$gethtml=getcontet($url);
echo $gethtml;
?>
不就可以完成楼主功能吗?
*
* 发送页面
*
*//////////////////////////////////////////////////////////////////////$host="192.168.20.204"; //地址 记得只能是主机地址,如www.163.com,不能使www.163.com/news.php等,也不能加http什么协议头
$report_path="/path/";
$url=$report_path."bw_i2_recv_bug_report_test.php"; //对方接收页面
$port=80; //端口$post_str="pid=我接收到了";$strlength = strlen( $post_str); $fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "POST ".$url." / HTTP/1.1\r\n"; //可修改,用“POST”或是“GET”方式传输和接收
$out .= "Content-type: application/x-www-form-urlencoded\n";
$out .= "Content-length: ".$strlength."\n\n";
$out .= $post_str."\n"; fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}/////////////////////////////////////////////////////////////////////
?><?php
/*
*
* 接收页面
*
*//////////////////////////////////////////////////////////////////////foreach($_POST as $key => $value)
$$key = $value;echo $pid;/////////////////////////////////////////////////////////////////////
?>
是不是他那边的服务器做了IP限制,以致于不能接受远程POST的数据呢?
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Referer: http://www.londonstockexchange.com\r\n";
function posttohost($url,$data,$referer) {
$url = parse_url($url);
if (!$url) return "couldn't parse url";
if (!isset($url['port'])) { $url['port'] = ""; }
if (!isset($url['query'])) { $url['query'] = ""; } $encoded = ""; while (list($k,$v) = each($data)) {
$encoded .= ($encoded ? "&" : "");
$encoded .= rawurlencode($k)."=".rawurlencode($v);
} $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80);
if (!$fp) return "Failed to open socket to $url[host]"; fputs($fp, sprintf("POST %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query']));
fputs($fp, "Host: $url[host]\n");
fputs($fp, "Referer: $referer");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($encoded) . "\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, "$encoded\n"); $line = fgets($fp,1024);
if (!eregi("^HTTP/1\.. 200", $line)) return; $results = ""; $inheader = 1;
while(!feof($fp)) {
$line = fgets($fp,1024);
if ($inheader && ($line == "\n" || $line == "\r\n")) {
$inheader = 0;
}
elseif (!$inheader) {
$results .= $line;
}
}
fclose($fp); return $results;
}