Get Document source After AJAX or js Action With P

2019-08-09 23:25发布

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)?

1条回答
老娘就宠你
2楼-- · 2019-08-09 23:55

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.

查看更多
登录 后发表回答