亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用PhantomJS提交表單

如何使用PhantomJS提交表單

料青山看我應如是 2019-12-02 08:04:37
我正在嘗試使用phantomJS(真棒的工具btw?。榫哂械卿洃{據的頁面提交表單,然后將目標頁面的內容輸出到stdout。我可以使用幻像訪問該表單并成功設置其值,但是我不太確定提交表單并輸出后續頁面內容的正確語法。到目前為止,我有:var page = new WebPage();var url = phantom.args[0];page.open(url, function (status) {  if (status !== 'success') {      console.log('Unable to access network');  } else {    console.log(page.evaluate(function () {      var arr = document.getElementsByClassName("login-form");      var i;      for (i=0; i < arr.length; i++) {        if (arr[i].getAttribute('method') == "POST") {          arr[i].elements["email"].value="[email protected]";          arr[i].elements["password"].value="mypassword";          // This part doesn't seem to work. It returns the content          // of the current page, not the content of the page after           // the submit has been executed. Am I correctly instrumenting          // the submit in Phantom?          arr[i].submit();          return document.querySelectorAll('html')[0].outerHTML;        }      }      return "failed :-(";    }));  }  phantom.exit();}
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 242 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號