简体   繁体   中英

How to get the value of document.location.href with PHP

i need to capture the value of an javascript code. To be more precise the document.location.href, but i need to do this with PHP.

Actually i'm doing this:

$html = file_get_html("http://server.camgate.ru/snapshot.php?camid=111013191059");

       $element = $html->find('img'); 
       $img =  $element->src;

and it shows progress.gif, that's cool, the problem is that i need to get the href of the javascript inside that webpage to show the image inside.

Like this:

$url = "http://server.camgate.ru/snapshot.php?camid=111013191059";

$html = file_get_html($url);
       $element = $html->find('script'); 
       $link =  $element->href;

       $data[]   = array("camara" =>"Camara 1", "imagen"=>$link);

the $html shows this:

<script>  \n    width=document.body.clientWidth;  \ndocument.location.href = \"http:\/\/camgate.ru\/showpix.php?id=111013191059&m=1013&d=171013&pix=171013035306.jpg\";      \n<\/script>

So i need to get the url posted there. But if i use the $element->href it shows null.

How can i get it?

Thanks in advance

You can draw Javascript with PHP but you can't do the reverse. If you need to pass data back to your PHP, the only way would be to use AJAX. Either that, or figure out the URL end on the PHP end beforehand.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM