我如何提交一个表单,并获得与幻影js之后的内容

How do I submit a form and get the content after that with phantom js?

本文关键字:幻影 js 之后 表单 何提交 提交 一个      更新时间:2023-09-26

我想提交一个表单,提交后得到页面的内容。我试着做:

      var page = require('webpage').create();
 page.onConsoleMessage = function(msg) {
console.log(msg);
 };
 page.open("http://www.mcservidores.com.br/login.php", function(status) {
if ( status === "success" ) {
    page.evaluate(function() {
          document.querySelector("input[name='username']").value = "myusername";
          document.querySelector("input[name='password']").value = "mypassword";
         document.querySelector("input[type='submit']").submit();
    });
    window.setTimeout(function () {
      page.render('colorwheel.png');
      phantom.exit();
    }, 5000);
    }
   });

您必须在提交表单之前收集表单数据,除非您在服务器上捕获它。当提交非ajax表单时,当前页面停止执行。