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提交時沒有與要求的對應,可能就會出錯。