php打开并填充表单,php – 创建一个’机器人’来填充带有一些页面的表单
表單通過發(fā)布數(shù)據(jù)來工作,因此您可以將數(shù)據(jù)發(fā)布到服務(wù)器,而不是使機器人在每個字段中鍵入內(nèi)容并單擊提交.
首先獲取表單字段名稱和表單的操作.
那么CURL:
//set POST variables
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname' => urlencode($last_name),
'fname' => urlencode($first_name),
'title' => urlencode($title),
'company' => urlencode($institution),
'age' => urlencode($age),
'email' => urlencode($email),
'phone' => urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
總結(jié)
以上是生活随笔為你收集整理的php打开并填充表单,php – 创建一个’机器人’来填充带有一些页面的表单的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab实现瑞利信道需要的步骤,基于
- 下一篇: php的框架目录,Laravel 框架目