1

When I compare the source code of a webpage in the browser with the source code I get from the code below,

$data = file_get_contents("http://www.someurl.com/loader.aspx");

it differs. The source code is not the same and I suspect that is caused because of some DOM manipulations.

Is it possible to get the HTML source code after the javascript and/or ajax manipulations programmaticly (with PHP)?

6
  • @jszobody No it doesn't, thanks for the heads up. Commented Nov 21, 2013 at 16:18
  • i want get the source code of that webpage and save it in varible with php with file-get-contents some html code that generated with js or ajax not recive Commented Nov 21, 2013 at 16:20
  • i want write some php script that's get source code of that site after all js or ajax effect ... Commented Nov 21, 2013 at 16:21
  • @MOB Did you look at my answer? file_get_contents will NOT evaluate Javascript code on the page, you have to use a third-party headless browser. Commented Nov 21, 2013 at 16:23
  • yes ... know see ... can show me some example ... thanx a lot Commented Nov 21, 2013 at 16:24

1 Answer 1

0

You will need to use a headless browser that can evaluate JavaScript on the page. One very popular option is PhantomJS.

Then look at PHP PhantomJS to see how you can control this headless browser from your PHP scripts.

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

1 Comment

unfortunately i cant use PHP PhantomJS for my work ... can help me for use this source and install it when i call PHP PhantomJS below err accourd Fatal error: Class 'JonnyW\PhantomJs\Client' not found in C:\xampp\htdocs\read\test\src\a.php on line 4

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.