自动填充和外部网站提交表单 [英] Auto fill and submit forms on external site
问题描述
我想知道一个人如何自动填充多种形式(使用 BOT /本地服务器
)在多个页面上使用AJAX或卷曲外部站点(PHP)的。
I was wondering how does one auto fill multiple forms (using bot/local server
) on multiple pages of external site (PHP) using ajax or curl.
例如一个网站 www.abc.com/index.php
有一个表格<形式GT; <输入名称='文本'>< /形式GT;这需要你
的 www.abc.com/fst.php
时,表单提交并有另一种形式的 www.abc.com/fst.php
,需要填写并提交了。我想自动从我的本地服务器上填写这两个表格。我如何实现这一目标?
For example a site www.abc.com/index.php
has a form <form> <input name='text'></form>
which takes you to the www.abc.com/fst.php
when the form is submitted and there is another form on www.abc.com/fst.php
that needs to be filled and submitted too. I want to automatically fill both form from my local server. How do i accomplish that?
推荐答案
最简单的方法就是使用类似的Greasemonkey(的 https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ ),但更好的方法是使用萤火'网'标签捕获当你填写表格,并重复这一职务,卷曲发后(的http:// PHP .NET /手动/ EN / book.curl.php )
The easiest way is to using something like greasemonkey ( https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ ), but the better solution is to use the firebug 'net' tab to capture the post sent when you fill out the form and repeat that post with CURL ( http://php.net/manual/en/book.curl.php )
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;
}
这篇关于自动填充和外部网站提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!