【问题标题】:Auto fill and submit forms on external site在外部网站上自动填写和提交表格
【发布时间】:2012-02-03 05:18:07
【问题描述】:

我想知道如何使用 ajax 或 curl 在外部网站 (PHP) 的多个页面上自动填写多个表单(使用 bot/local server)。

例如,网站www.abc.com/index.php 有一个表单<form> <input name='text'></form>,当提交表单时,它会将您带到www.abc.com/fst.php,而www.abc.com/fst.php 上还有另一个表单需要填写和提交。我想从我的本地服务器自动填写这两个表格。我如何做到这一点?

【问题讨论】:

    标签: php ajax curl bots


    【解决方案1】:

    最简单的方法是使用类似greasemonkey (https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) 之类的方法,但更好的解决方案是使用firebug 'net' 选项卡捕获填写表格时发送的帖子并使用CURL (@ 987654322@)

    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; 
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-12
      • 1970-01-01
      • 2018-11-02
      • 2014-06-12
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      相关资源
      最近更新 更多