I send request to website for get content by file_get_contents e.g.
$html=file_get_contents('http://....');
var_dump(HTML::encode($html));
but html body tag fill by js so I cant get body. body is like this
<body> </body>
How can get body by php
I send request to website for get content by file_get_contents e.g.
$html=file_get_contents('http://....');
var_dump(HTML::encode($html));
but html body tag fill by js so I cant get body. body is like this
<body> </body>
How can get body by php
You can use tools specifically designed for this purpose.
A popular solution is Symfony's Panther library.
Given the page you are trying to get content for is hosted at http://example.com, and an element with the id "myElement" is added to the page using javascript (indicating the javascript we are dependent on has finished executing), we could run the following code:
$client = \Symfony\Component\Panther\Client::createChromeClient();
$crawler = $client->request('GET', 'http://example.com');
$client->waitFor('#myElement');
var_dump($crawler->html());
if the target website contents are being populated by the script then you cannot access it via above method as there is no area provided to execute the script to populate the body when you do a PHP call like above. alternatively, you may use ajax to get the target website content which also will have restrictions based on origin/request which only possible if you have access to the target website or you can use an iframe and I don't know which is suitable for what you really need to accomplish anyway?