Recover HTML updated by javascript using DOM

3

Is there any way to retrieve updated HTML using DOM? The original HTML page is from a remote site, which does not have internal access, and it looks like this:

<div class="content" id="content">
        loading
</div>

When we click on a button within the page, javascript acts, and div is modified, getting something like:

<div class="content" id="content">
            <span class="values">text1</span>
            <span class="values">text2</span>
    </div>

I need to retrieve the texts of tags <span> , which in this case was javascript who inserted it. I used DOM:

$html = file_get_contents("http://sitetal.com");
$DOM =  new DOMDocument();
$DOM->loadHTML($html);
$xpath = new DomXpath($DOM);
$span = $xpath->query('//*[contains(concat(" ", normalize-space(@class), " "), "values")]');
foreach($span as $spanvalue){
    $sp = floatval($spanvalue[0]->nodeValue);
    $spaValue = $sp;

echo $spaValue;
}

But of course nothing is returned to me because <span> has not yet been created, it will only be created when the button is clicked on the site, and javascript insert the information. is there any way to retrieve the updated HTML, to read the values that were generated in <span> ? For me to retrieve the text 1 and text 2.?

    
asked by anonymous 04.03.2015 / 21:19

1 answer

1

The short, thick answer is no, it is not possible to simulate user behavior with PHP requests .

User behaviors can only be done through Javascript and an interpreter is required, in case browsers have one.

When you send a request in PHP, you are only requesting dados , you can not emulate behaviors on that data.

    
04.03.2015 / 22:04