3
I’m working on a project where I have to do the 'parser'
from a remote site to change various contents of it, everything is fine, except the functions that involves javascript/ajax.
Functions do not work, website 'parseado'
always returns me an error
"sorry we’re in trouble'',
but this error occurs due to javascript.
I was wearing a proxy em PHP
to make the 'parser'
, but for being slow, I wanted to make my own, and it’s nothing more than a "link changer":
function parserSite($link){
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$html = file_get_contents($link , false, $context);
$results = preg_replace('/href="(https:\/\/)?([^"]+)"/', "href=\"https://sitetal.com\\2\"", $html);
$results = preg_replace('/src="(https:\/\/)?([^"]+)"/', "src=\"https://sitetal.com\\2\"", $results);
reuturn $results
}
$link = $_GET["link"];
$site = parserSite($link);
echo $site;
The site works all right, except the javascript's
.
In the proxy I used, the same error occurred when I disabled the option "Override Enable Javascript", when this option was enabled, everything worked normally.
But what’s this about "Override Enable Javascript"?
it is possible for me to do for my script?
Posted in PHP e Javascript
because I don’t know for sure which of the two languages I’ll have to use for such.
Thank you so much! I made my browser headless and gave it right ;)
– Cassiano José