http 请求 POST 与 javascript 使用 Java/Python?

http request POST with javascript using Java/Python?

我尝试连接到 http://leya2.eu/。 我尝试了很多东西...问题是 运行 网站上的脚本。 我确实想用 Python 或 Java 来做...我最后尝试的是 PhatomJS,但我每次都只得到 BlazingFast 页面。

问题是这个脚本:

var XHR="onload"in new XMLHttpRequest?XMLHttpRequest:XDomainRequest,xhr=new XHR;var ww = $(window).width();xhr.open("GET","/___S___/?rid=CLYVwTkbSONnYzhmsnBo6AhooeCoHsgxayFRarvktEYBIdpcL2aQPVoW7U32QGrh&sid=" + ww +"&d=leya2.eu&tz=1500505915.508",true),xhr.onreadystatechange=function(){if(4==xhr.readyState&&(xhr.status==200)){var t=document.createElement("script");t.type="text/javascript",t.text=xhr.responseText,document.body.appendChild(t)}},xhr.send(null);function wait(){}; setTimeout(wait(),4000);

所以也许有人有想法?

我的标准脚本是这样的:

from urllib.request import urlopen
from urllib.parse import urlencode

url = 'http://evidence-server.com/?s=login'
response = urlopen(url, urlencode(data).encode("utf-8"))
content = response.read().decode(response.headers.get_content_charset())
print(content)

这一切就在附近:

var page = require("webpage").create(),
    url = "http://leya2.eu/";

function onPageReady() {
    var htmlContent = page.evaluate(function () {
        return document.documentElement.outerHTML;
    });

    console.log(htmlContent);

    phantom.exit();
}
page.open(url, function (status) {
    if (status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit();
    } else {
        window.setTimeout(function () {
            console.log(htmlContent);
            phantom.exit();
        }, 5000); 
    }
});

这是一个用于访问您的目标站点的有效脚本。注意一个内置变量 page.content:

var page = require("webpage").create(),
    url = "http://leya2.eu/";


page.open(url, function (status) {
    if (status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit();
    } else {
        window.setTimeout(function () {
            page.render("leya2.jpg");
            console.log(page.content);
            phantom.exit();
        }, 10000); 
    }
});

在 PhantomJS 版本 2.5b 上为 Windows 生成 this screenshot