curl模擬提交

2021-07-24 13:54:29 字數 907 閱讀 7206

<?php

header("content-type:text/html;charset=utf8");

//初始化curl

$ch=curl_init();

//print_r($ch);

//設定curl引數

curl_setopt($ch,curlopt_url,"");//設定url路徑

curl_setopt($ch,curlopt_returntransfer,1);//獲取的資訊以檔案流的形式返回而不是直接輸出

curl_setopt($ch,curlopt_header,0);//啟用時會將標頭檔案資訊作為資料流輸出

//執行並獲取html檔案內容

$output=curl_exec($ch);

//釋放curl控制代碼

curl_close($ch);

<?php

$url = "index.php?m=index&a=login";

$post_data = array ("1409phpe0032" => "bob","key" => "1265");

$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);

curl模擬提交

function curl post url,post data curl post array name caiknife email caiknife gmail.com var dump data get方式實現 初始化 curl curl init 設定抓取的url curl setopt ...

curl模擬post請求提交

php view plain copy header content type text html charset utf 8 function curlpost url data method curl setopt ch curlopt returntransfer,true tmpinfo c...

curl模擬post請求提交

header content type text html charset utf 8 function curlpost url,data,method curl setopt ch,curlopt returntransfer,true tmpinfo curl exec ch 6.執行 if ...