简体   繁体   中英

Easiest Way Of Getting Elements Unreadable by Simple HTML Dom Parser in PHP

Let's say that a simple web application, like below, runs, utilizing Simple HTML Dom Parser.

<?php 
  include('simple_html_dom.php'); 

  $html = file_get_html('http://someurl.com');
  echo $html;
 ?>

As expected, everything comes up EXCEPT for one element, a div of class .addedDiv , which appears to be injected by JS. In the simplest and most inclusive way, can you please demonstrate how that one element can be retrieved with the minimal amount of code, hopefully with an example, (update ) preferably inline and easy to implement for most people, be it with PHP, AJAX, or, I don't know, iFrame hack? Thanks in advance for any and all help.

UPDATE:

Also, if it helps, I don't actually need (or want) it outputted along with everything else. I just need an attribute from it to simulate some additional functionality. Therefore, if it is of any difference, I do not need to have to have a '$html' that outputs everything of a website to the screen (if I did, I'd just use an iframe).

I think you can use phantomjs module. you need to require install it.

phantomjs is command line utility, so in php you can execute it by exec() command and get expected foutput.

For more you need to learn how to get content of HTML after modified by JS from here http://phantomjs.org/api/webpage/property/content.html

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