2012-01-05 43 views
3

ajaxやcurlを使用して複数のフォーム(bot/local serverを使用)を複数の外部サイト(PHP)で自動入力する方法が不思議でした。例えば外部サイトのフォームを自動入力して送信する

フォームを送信して充填され、あまりにも提出する必要がwww.abc.com/fst.php上の別のフォームがあるされている場合www.abc.com/fst.phpに移動しますフォーム<form> <input name='text'></form>を持っていwww.abc.com/index.phpサイト。ローカルサーバーから両方のフォームを自動的に入力したいと思います。どのように私はそれを達成するのですか?

答えて

3

最も簡単な方法は、グリースモンキー(https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/)のようなものを使用することですが、よりよい解決策は、フォームに必要事項を記入時に送信ポストをキャプチャし、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; 
} 
関連する問題