dongzi3805 2017-08-25 17:07
浏览 27

PHP在页面完全加载后从页面获取元素

I want to take content of #result from this page,but that div is being loaded after the page is loaded.Now i use this code

$url = 'http://www.fantasynamegenerators.com/alien-names.php#.WaBXGZOg-9Y';
$content = file_get_contents($url);
$first_step = explode( '<div id="result">' , $content );
$second_step = explode("</div>" , $first_step[1] );

To get content of that div,but because that div is getting loaded after the page,it returns the whole page.Now how can i tell php to wait till the page is fully loaded and then take it's content

  • 写回答

1条回答 默认 最新

  • dourao3960 2017-08-25 17:20
    关注

    You can't gets result of this part of page that isn't in source code. This div is fulled with data using code written with JavaScript in alienNames.js. By running file_get_contents() you are downloading only HTML structure of give page...

    Summarizing, You can't execute js script with php.

    评论

报告相同问题?