Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP read generated content 1

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
Is there a way to get PHP to file_get_contents() on the (javascript) generated source instead of just the source?

just like the "view generated source" option in the webdeveloper toolbar.

i guess it would have to retrieve a page, execute it, and then read the code right?

what about doing it in a server installed firefox via exec/system() ?


site | blog | aplis |
 
i know of no way to achieve this. and in fact some browsers will not give you the javascript generated source when selecting view->source. firefox is an exception.

you would need to write an application to parse and execute the javascript and have cognisance of the DOM. one thing that springs to mind as a possibility is a javascript server like jaxer. perhaps that might have an api you could use. or failing that you could get jaxer to write to STDOUT or a file and pick up the data from there. i have a fear that you will run into cross-site scripting issues but jaxer might be a good starting point.
 
I do this in my "site annotation" package. It relies heavily on JavaScript, though.

See (it will not run a php script but it will show the source, as it is part of a subversion repository)

document.documentElement.innerHTML will get you the page's content, but there is alas no way to retrieve the type tag (html strict, loose, xhtml).

The above php file shows a popup window that is called from javascript when a site annotation link is clicked. window.opener is the original page, that I want to capture.

Hope this helps.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top