Get Document source After AJAX or js Action With PHP

早过忘川 提交于 2019-12-11 08:42:23

问题


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:


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.



来源:https://stackoverflow.com/questions/20126138/get-document-source-after-ajax-or-js-action-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!