0

I'm trying to retrieve the source code of a page, but the problem is that some of the content loads through AJAX or similar.. this content doesn't appear in the normal source code fetched through PHP's file_get_contents.

Is there any way to get this? (On the server side, not via browser developer tools and such.)

4
  • Run the AJAX and fetch the things they load? That's really the only way. Commented Mar 19, 2011 at 19:40
  • 1
    Unless you basically build a browser in PHP, there's no way to "run" javascript in a fetched page. Commented Mar 19, 2011 at 19:45
  • I havent got access to the site i want the source code of, but what exactly do you mean? Commented Mar 19, 2011 at 19:49
  • 3
    possible duplicate of How can you retrieve a pages source code (after javascript has ran) using PHP? Commented Sep 2, 2015 at 18:36

2 Answers 2

2

Try the Web Developer extension for firefox. You can right click a page and click "View Generated Source" from one of the Web Developer options.

Hope this is what you needed.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry this didnt say in the original question, but it has to be some code thats able to run automaticly on a server. So Firefox wont do :\
Marc B is correct in that case. AJAX is basically the browser running some javascript which modifies the source code of the page. If you can modify the AJAX driven page, you could write a fallback for browsers with no javascript, which would solve your problem.
0

When ever i need to test this i use something like FireBug (for firefox but there's a 'light' version that can be used on other browsers).

Firebug is great for this since it will show you the exact code (html, javascript,..) that the browser is using to generate the page

2 Comments

Sorry this didnt say in the original question, but it has to be some code thats able to run automaticly on a server. So Firefox wont do :\
If you're trying to get the server side code before there server parses it (like php, asp, java,...) then you're out of luck. With out physical access to the server theres no way to get it un parsed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.