Php 在外部站点上自动填写和提交表单
我想知道如何使用ajax或curl在外部站点(PHP)的多个页面上自动填充多个表单(使用Php 在外部站点上自动填写和提交表单,php,ajax,curl,bots,Php,Ajax,Curl,Bots,我想知道如何使用ajax或curl在外部站点(PHP)的多个页面上自动填充多个表单(使用bot/localserver) 例如,一个网站www.abc.com/index.php有一个表单,当表单提交时,它会将您带到www.abc.com/fst.php,而www.abc.com/fst.php上还有另一个表单也需要填写和提交。我想从本地服务器自动填写这两个表单。我如何做到这一点 最简单的方法是使用greasemonkey()之类的工具,但更好的解决方案是使用firebug“net”选项卡捕获填
bot/localserver
)
例如,一个网站
www.abc.com/index.php
有一个表单
,当表单提交时,它会将您带到www.abc.com/fst.php
,而www.abc.com/fst.php
上还有另一个表单也需要填写和提交。我想从本地服务器自动填写这两个表单。我如何做到这一点 最简单的方法是使用greasemonkey()之类的工具,但更好的解决方案是使用firebug“net”选项卡捕获填写表单时发送的帖子,并使用CURL()重复该帖子
function post($url,$data) {
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file);
curl_setopt($process, CURLOPT_ENCODING , $this->compression);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
if ($this->proxy) curl_setopt($process, CURLOPT_PROXY, $this->proxy);
curl_setopt($process, CURLOPT_POSTFIELDS, $data);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($process, CURLOPT_POST, 1);
$return = curl_exec($process);
curl_close($process);
return $return;
}