2016-05-02 19 views
-1

ウェブサーバー上でphantomjsとcasperjsが動作しています。フォーム上にフォームと名前と電子メールアドレスの2つのフィールドがあるWebページがあります。phpからcasperjsへの複数の変数の受け渡し

キャスタースクリプトに変数として「名前」と「メール」の両方を入力する必要があります。

Pass parameter from php to casperjs/phantomjs

http://phantomjs.org/api/system/property/platform.html

を読んでから、私はあなたがVARシステムおよびVAR引数を配置する必要がありますが、それはすべて私にはダブルダッチのように思える理解しています。

PHPコード

$name = $_POST['user_input']; 
$email = $_POST['user_input']; 
putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); 
exec('/usr/local/bin/casperjs hello.js $name $email 2>&1',$output); 

print_r($output); 

私は1つの引数に両方を取得し、それらを分割する必要がありますが、どのように私はそれをやって行くだろう、それのルックスからcasperjsコード

var system = require('system'); 
var args = system.args; 
var name = args 
var email = args 

var casper = require('casper').create({ 
    verbose: true, 
}); 
casper.start('website url'); 



casper.then(function() { 
    casper.wait(5000); 
     this.echo("wait for 5 seconds."); 

}); 
casper.then(function() { 

    this.sendKeys('#firstname', name); 
    this.sendKeys('#thereemail', email); 
    this.click('.button'); 

編集:投稿方法は

+1

[PHPからJavaScriptへ変数とデータを渡す方法は?](http://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to) -javascript) –

+0

[CasperJSスクリプトに変数を渡す方法は?](http://stackoverflow.com/questions/21765178/how-to-pass-a-variable-to-a- casperjs-script-through-the-command-line) – Vaviloff

答えて

関連する問題