我尝试连接到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);
}
});
答案 0 :(得分:0)
这是一个访问目标网站的工作脚本。请注意内置变量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);
}
});
在适用于Windows的PhantomJS 2.5b版本上生成this screenshot。