2017-12-04 12 views
1

私はこのスクリプトを使ってquoraにログインしました。 quoraのNightmare.jsスクリプトが正しく動作しない

var Nightmare = require('nightmare'); 
var nightmare = Nightmare({ show: true }); 

nightmare 
    .goto('https://www.quora.com/') 
    .type('input[name="email"]','[email protected]') 
    .type('input[type="password"]','pass123') 
    .click('input[type="submit"]') 
    .wait(5000) 
    .click('.disable_click_on_edit_mode') 
    .wait(5000) 
    .evaluate(function() { 
    return document.querySelectorAll('.question_link').href; 
    }) 
    .end() 
    .then(function (result) { 
    console.log(result); 
    }) 
    .catch(function (error) { 
    console.error('Error message:', error); 
    }); 

これは、簡単に自分のパスワードフィールドに電子メールの分野で私の電子メールとパスワードを入力して、ログインボタンをクリックしてQuoraのにはログインする必要があります。 しかし、私はこのスクリプトを実行すると、メールとパスワードの両方をメールフィールドに入力してエラーになります。

答えて

1

[OK]をクリックして、別の解決策を見つけました。そのログインページには2つの入力ボックスしかないので、これを使用できます:

nightmare 
    .goto('https://www.quora.com/') 
    .type('input[tabindex="1"]','[email protected]') 
    .type('input[tabindex="2"]','pass123') 
    .click('input[type="submit"]') 
    .wait(5000) 
    .click('.disable_click_on_edit_mode') 
    .wait(5000) 
    .evaluate(function() { 
    return document.querySelectorAll('.question_link').href; 
    }) 
関連する問題