2017-11-11 218 views
0

我試圖從Facebook配置文件中取消基本信息。我的最終目標是通過使用casperjs來獲得例如某人的年齡(如果信息可以在臉書上獲得)。casperjs /填寫並提交表格在facebook錯誤

所以我安裝了Casper.js。 我開始填寫密碼和郵件以便第二次訪問搜索字段。

但是:

ReferenceError: Can't find variable: casper

phantomjs://code/scrapin.js:1 in global code :0 in injectJs phantomjs://code/bootstrap.js:456 Hint: you may want to use the casperjs test command.

phantomjs://code/bootstrap.js:148 in onPhantomError

這裏是我的代碼:

 casper.start('https://www.facebook.com/', function() { 

    this.fill('form[id="login-form"]', { 
     'username': 'my mail adress', 
     'password': 'my fb password' 
    }, true); 
    }); 

casper.then(function() { 
    this.echo(this.getTitle()); 
}); 

casper.run(); 

我精確,以至於Casper.js正在我的電腦上,它同樣適用於其他任務。

我敢肯定這是一個基本的錯誤,我完全是一個JavaScript的初學者! 請原諒我的英語不好,我盡力而爲;)

謝謝!

回答

0

在腳本的頂部,當你要運行腳本,請使用以下運行它添加這一行,

var casper = require('casper').create(); 

然後,

casperjs myPreciousScript.js