當前位置:首頁 » 編程語言 » php模擬

php模擬

發布時間: 2024-11-11 14:50:38

『壹』 php怎麼模擬瀏覽器發送get請求

  1. get請求?直接跳轉裡面帶上參數就行了

  2. 代碼如下:

    <?php
    header('Location:http://xxx/yyy?ddd=1&kkk=2');
    ?>

『貳』 如何通過php程序模擬用戶登錄

模擬用戶可以用php的curl的post,例如
$url = "http://www.uzuzuz.com";
$post_data = array ("username" => "uzuzuz","password" => "12345");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post數據
curl_setopt($ch, CURLOPT_POST, 1);
// post的變數
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//列印獲得的數據
print_r($output);

具體參考:http://www.uzuzuz.com/article/4.html

『叄』 PHP中模擬登錄的驗證碼問題應該如何解決

基本思路:

首先獲取一個cookies值,再帶著這個cookies去獲取驗證碼圖片,你再帶著驗證碼值和登錄數據去模擬post登錄。下面是一個模擬獲取驗證碼的。

這里忽略獲取cookies的過程。注意文件為UTF-8無BOM格式

?php
header('Content-Type:image/png');
$url="http://hbyw.e21.e.cn/global/gd.php";//圖片鏈接
$ch=curl_init();
//Cookie:PHPSESSID=
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_COOKIE,'PHPSESSID=');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch,CURLOPT_TIMEOUT,0);//忽略超時
curl_setopt($ch,CURLOPT_NOBODY,false);
$str=curl_exec($ch);
curl_close($ch);
熱點內容
蝸牛游戲安卓手機怎麼更換賬號 發布:2025-03-17 13:41:49 瀏覽:321
為什麼人買一個蘋果一個安卓 發布:2025-03-17 13:36:59 瀏覽:438
三星手機簡訊在那個文件夾 發布:2025-03-17 13:31:51 瀏覽:194
安卓皇帝隱藏劇情在哪裡 發布:2025-03-17 13:18:53 瀏覽:507
新版安卓為什麼不兼容 發布:2025-03-17 13:18:49 瀏覽:483
s3哪個配置性價比高 發布:2025-03-17 13:06:09 瀏覽:320
氣體壓縮能量 發布:2025-03-17 13:00:16 瀏覽:78
壓縮油19 發布:2025-03-17 12:25:29 瀏覽:858
linux上網代理 發布:2025-03-17 12:23:56 瀏覽:361
c是高級語言嗎 發布:2025-03-17 12:16:31 瀏覽:525