Php – how to click using simple html dom parse in php

PHPsimple-html-domweb scrapingweb-crawler

I am trying to click on href attribute
Here is my sample html

<ul>
  <li>
     <a href='http://www.google.com'>Google</a>
  </li>
</ul>

And Here is my php code

<?php 
  require_once('classes/simple_html_dom.php');
  $html = file_get_html("/var/www/html/dk/PHP_SCRAPPING/google.html");
  echo $html->find("ul li a",0)->href;
?>

Output is

http://www.google.com

I just want to click on this url. How to do that?
Please don't tell me to do this

file_get_html($html->find("ul li a",0)->href);

I am looking for method which can click on any href by using simple html dom.

Best Answer

You can't do that in PHP since all PHP code is executed server side and not client side. The PHP code doesn't run in a browser at all, so in essence there is no link to click.

If you want to script things client side, you'd need to resort to javascript. Although any sane browser won't let you emulate a click in Javascript for security reasons.

I think you need to read up on what exactly you're doing.