Problem with phantomJs

Hi,

I have an error with phantomjs, I just want to get the page data, it works well with other pages.

It is not possible to modify the WEB, so the script must be modified in phantomjs

When there is “” on the page, it tells me "Can’t find variable: loadData and points to the body onload line as an error, of course I can’t read the data and I get nothing .

loadData () is a (relevant) function that obtains the data.

Unmodifiable page code:

<html>
<head>
<title>Headless remote debugging</title>
<style>
</style>
<script>
const fetchjson = (url) => fetch(url).then(r => r.json());
function loadData() {
const getList = fetchjson("/json/list");
const getVersion = fetchjson('/json/version');
Promise.all([getList, getVersion]).then(parseResults);
}

function parseResults([listData, versionData]){
const version = versionData['WebKit-Version'];
const hash = version.match(/s(@(b[0-9a-f]{5,40}b)/)[1];
listData.forEach(item => appendItem(item, hash));
}

function appendItem(item, hash) {
let link;
if (item.devtoolsFrontendUrl) {
link = document.createElement("a");
var devtoolsFrontendUrl = item.devtoolsFrontendUrl.replace(//devtools//,'');
link.href = https://chrome-devtools-frontend.appspot.com/serve_file/@${hash}/${devtoolsFrontendUrl}&remoteFrontend=true;
link.title = item.title;
} else {
link = document.createElement("div");
link.title = "The tab already has active debugging session";
}

var text = document.createElement("div");
if (item.title)
text.textContent = item.title;
else
text.textContent = "(untitled tab)";
if (item.faviconUrl)
text.style.cssText = "background-image:url(" + item.faviconUrl + ")";
link.appendChild(text);

var p = document.createElement("p");
p.appendChild(link);

document.getElementById("items").appendChild(p);
}
</script>
</head>
<body onload='loadData()'>
<div id='caption'>Inspectable WebContents</div>
<div id='items'></div>
</body>
</html>

Thanks.

Are you suing phantomjs with Linux and phoenix, plus hound?

If you do here is a guide I wrote for a problem with it