What is a javascript Override?

3

I'm working on a project where I have to do 'parser' of a remote site to change various contents of it, everything is right except the functions that involve javascript/ajax. The functions do not work, the 'parseado' site always returns me an error

  

"Sorry we're in trouble,"

but this error occurs because of javascript. I was using proxy em PHP to make 'parser' , but for being slow, I wanted to make my own, and nothing else is 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 everything right except the javascript's . In the proxy that I used, the same error occurred when I turned off the "Override native Javascript" option when this option was enabled, everything worked normally. But what is this " Override native Javascript?" Is it possible for me to do it for my script? I put PHP e Javascript because I'm not sure which of the two languages I have to use for it.

    
asked by anonymous 20.03.2015 / 17:45

1 answer

3

You are having this difference between the browser-accessed site and the download via PHP because the website in question probably uses javascript to render your parts, what you can do is use a headless browser to simulate a browser by accessing the site.

One suggestion is to use PhantomJS , perhaps with this library to use it through php

    
21.03.2015 / 00:55