本文目錄一覽:
- 1、PHP怎樣模擬登錄教務系統?最好有源碼實例。
- 2、php能實現模擬登陸嗎?
- 3、如何通過php程序模擬用戶登錄
- 4、在PHP中如何模擬HTTP_USER_AGENT
- 5、PHP里模擬Post提交是什麼意思?
PHP怎樣模擬登錄教務系統?最好有源碼實例。
前幾天剛實現了一個,難點主要有3塊:
1:http頭部模擬
2:在使用curl做POST的時候, 當要POST的數據大於1024位元組的時候, curl並不會直接就發起POST請求, 而是會分為倆步,
3:post的數據,有幾個欄位是用js計算出的,需要用php模擬出
附:curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($data));
php能實現模擬登陸嗎?
用php模擬登陸主要分為三部分 1. post數據。 2.根據返回的http頭,從中截出cookie段。 3.偽造http頭髮送請求。 我這裡以用php抓取163相冊的需要密碼才能訪問的目錄為例。 ?php function posttohost($url, $data) //post數據 { $url = parse_url($url); if (!$url) return “couldn’t parse url”; if (!isset($url[‘port’])) { $url[‘port’] = “”; } if (!isset($url[‘query’])) { $url[‘query’] = “”; } $encoded = “”; foreach ($data as $k=$v) { $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, “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; }
如何通過php程序模擬用戶登錄
模擬用戶可以用php的curl的post,例如
$url = “”;
$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);
具體參考:
在PHP中如何模擬HTTP_USER_AGENT
在curl里可以設置UA
?php
//client
$ch = curl_init();
curl_setopt_array($ch,
array(
CURLOPT_URL = ”,
CURLOPT_USERAGENT = “YeRenChai_v1.0”,
CURLOPT_RETURNTRANSFER = True,
CURLOPT_FOLLOWLOCATION = True,
)
);
$response = curl_exec($ch);
if(!$response) exit(curl_error($ch));
var_dump($response);
?
?php //server
echo $_SERVER[‘HTTP_USER_AGENT’];
?
PHP里模擬Post提交是什麼意思?
php
表單提交常見的就是post和get
模擬提交就是通過其他技術達到post或get的效果
php
常見的模擬就是curl方式了
作用比如說刷票
每次提交它可以模擬ip
逃過ip限制
圖片上傳
可以post提交
不用模擬
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/288555.html