1. php页面向外网的asp页面post表单数据实现模拟登陆,怎么实现
这个实现方式太多了。可以用ajax跨域提交数据。可以用PHP的扩展类curl进行模样表单提交。用JS跨域一直是一个问题,但可以实现,用jquery的时候你要注意这点,只有ajax()这个方法。用curl是不存在跨域问题的。但你要注意的是:curl模样表单提交的时候,提交的字段一定要按字母集的顺序(abcdef..)中文字符一定要用urlencode()函数进行编码就可以了。要怎么提交,下一个firebug查看一下就知道了
2. PHP 模拟HTTP发送POST请求
用php模拟登陆主要分为三部分1. post数据。2.根据返回的http头,从中截出cookie段。3.伪造http头发送请求。 我这里以用php抓取163相册的需要密码才能访问的目录为例。<?phpfunction posttohost($url, $data) //post数据if (!isset($url['query'])) $encoded = "";foreach ($data as $k=>$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, "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)) elseif ($inheader) }fclose($fp);return $results;} 答案补充 function getjs($juser,$jaid,$jcookie) //伪造http头 答案补充 else fclose( $socket ); return $ret;}}$iurl=' http://photo.163.com/photos/'.$iuser.'/'.$aid.'/';$idata=array ('pass'=>$pass,'checking'=>'1'); //通过winsock抓包发现,输入访问密码,会向163相册发送 pass=密码&checking=1$mystr=posttohost($iurl,$idata);$pattern='/HALFORDER=(.*?);/';preg_match($pattern,$mystr,$out);$str=getjs($iuser,$aid,$out[1]);echo $str;?>
3. PHP里模拟Post提交是什么意思
php
表单提交常见的就是post和get
模拟提交就是通过其他技术达到post或get的效果
php
常见的模拟就是curl方式了
作用比如说刷票
每次提交它可以模拟ip
逃过ip限制
图片上传
可以post提交
不用模拟
4. 请教大神,关于PHP模拟登录的,不知道如何构建post,主要是<input type="button"...不懂, 表单如下:
这个你首先在浏览器(火狐看的清除)上登录下,然后抓个包(即把post表单获取到),post表单属于http里面主体信息了,然后把头信息的cookie获取到,综合一下就可以模拟登录了。大概格式如下:
$socket = "POST /t/telnet/index.php HTTP/1.1\r\n";
$socket .= "Host: localhost\r\n";
$socket .= "Content-type: application/x-www-form-urlencoded\r\n";
$socket .= "Cookie: cookie的东西";
$socket .= "Content-length: 20\r\n";
$socket .= "\r\n";
$socket .= "主体信息\r\n";
$socket .= "\r\n";
$fh = fsockopen(host,port,errno,errstr, 30);
fwrite($fh,$socket);
fclose($fh);
大概就是这样,自己可以慢慢研究测试。
5. php curl模拟post登陆怎么知道登陆成功了
表单提交后服务器要返回登录结果页面,从结果页面判断登录是否成功。登录失败有提示信息,根据提示信息就可以判断。
6. php实现模拟post请求用法实例
本文实例讲述了php实现模拟post请求的方法。分享给大家供大家参考。具体如下:
class
Request{
public
static
function
post($url,
$post_data
=
'',
$timeout
=
5){//curl
$ch
=
curl_init();
curl_setopt
($ch,
CURLOPT_URL,
$url);
curl_setopt
($ch,
CURLOPT_POST,
1);
if($post_data
!=
''){
curl_setopt($ch,
CURLOPT_POSTFIELDS,
$post_data);
}
curl_setopt
($ch,
CURLOPT_RETURNTRANSFER,
1);
curl_setopt
($ch,
CURLOPT_CONNECTTIMEOUT,
$timeout);
curl_setopt($ch,
CURLOPT_HEADER,
false);
$file_contents
=
curl_exec($ch);
curl_close($ch);
return
$file_contents;
}
public
static
function
post2($url,
$data=array()){//file_get_content
$postdata
=
http_build_query(
$data
);
$opts
=
array('http'
=>
array(
'method'
=>
'POST',
'header'
=>
'Content-type:
application/x-www-form-urlencoded',
'content'
=>
$postdata
)
);
$context
=
stream_context_create($opts);
$result
=
file_get_contents($url,
false,
$context);
return
$result;
}
public
static
function
post3($host,$path,$query,$others=''){//fsocket
$post="POST
$path
HTTP/1.1\r\nHost:
$host\r\n";
$post.="Content-type:
application/x-www-form-";
$post.="urlencoded\r\n${others}";
$post.="User-Agent:
Mozilla
4.0\r\nContent-length:
";
$post.=strlen($query)."\r\nConnection:
close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return
$r;
}
}
$url='http://******/con/Inter.php';
$data=Request::post($url,array('api'=>'tag_list'));
$data2=Request::post2($url,array('api'=>'tag_list'));
echo
$data;
希望本文所述对大家的php程序设计有所帮助。
7. php 模拟登录,post到多个地址怎么做
$url = ''; //POST地址
$password = ''; //密码
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'username='.$_COOKIE['username'].'&password='.$password);
/**
* 如果$url是https则需要取消下面两行注释
* curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
* curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
*/
curl_exec($curl);
curl_close($curl);
8. PHP 5.2用POST方式登录,求解如何写
HTML中:(头尾的head、body之类的我就省了)
<formaction="xxx.php"method="post">
用户名:<inputtype="text"name="name"/><br/>
密码:<inputtype="password"name="password"/><br/>
<inputtype="submit"value="登录"/>
</form>
PHP中:
<?php
//HTML的form表单中,action指向此PHP文件,method="post"时,利用$_POST即可获取到提交的内容
if($_POST['name']=='user'&&$_POST['password']=='123456'){
echo'Y';
}else{
echo'N';
}
//直接使用if判断,如果用户名为user,密码为123456,则输出Y,否则为N
?>
9. 腾讯PHP面试题,PHP如何模拟POST提交登录求详细代码
大概流程是
先构建要传输的数据
再使用php的stocket模拟post请求
例子,比如我打开这个页面所用到的数据就是(这里用的是GET请求,改成POST就行了)
$fp=fsockopen(主机ip,端口号);
fputs($fp,数据字符串);
while(!feof($fp)){
//这里是输出请求所得到的回应数据
$result.=fgets($fp,128);
}
更多请自行网络php模拟post请求
因为我以前在工程实例中做过,所以比较了解
纯手打,望采纳
话说,这个问题过了就能进腾讯?门槛太低了吧。。。
10. php模拟post方式访问网页,显示盗用页面无法访问
模拟post提交的时候,根据目标网页限制的不同,需要采用不同的方法。
比如:
某些网页需要登录,这时候需要将登录的sessio(cookie)数据要一起发送;
再比如:
某些网页会检查发送来的请求来源(Referer)、浏览器的类型(User-Agent) ,如果模拟post提交时没有与要求的对应,可能就会出错。