2017-12-04 20 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

좋아, 나는 노력하고 또 다른 해결책을 발견했다. 로그인 페이지에는 입력란이 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; 
    })