简体   繁体   English

将网络浏览器嵌入php脚本中

[英]Embedding a web browser within a php script

In my project I have to do some screen scrapping.The source pages return data after executing the javascript embedded within them.In my php script I fetch the page using file_get_contents() and as usual,it returns the page simply as text.My question is that,is there a way to get the final output from the webpage (the output after executing javascript). 在我的项目中,我必须进行一些屏幕抓取。在执行源代码页面后,源页面返回数据。在我的PHP脚本中,我使用file_get_contents()获取页面,并且像往常一样,它仅以文本形式返回页面。就是这样,有没有一种方法可以从网页获取最终输出(执行javascript后的输出)。

I know some of you might suggest embedding a webbrowser inside and using that to execute the page.But how to do that?.Is there a working browser available.Or is there executable non GUI versions of opensource browsers such as chromium,so that I can run it as a CGI script or something 我知道你们中的一些人可能建议将Web浏览器嵌入其中并使用它来执行页面。但是该怎么做呢?是否有可用的浏览器可用?或者是否有可执行的非GUI版本的开源浏览器(例如Chrome),以便我可以将其作为CGI脚本运行

You will have to have some real browser like client for this, php alone won't cut it. 您将必须拥有一些像客户端这样的真正的浏览器,仅靠php不会成功。 For automation purposes you are most likely want a "headless" (without gui) browser like PhantomJS (the new hotness). 为了实现自动化,您很可能需要像PhantomJS (新功能)这样的“无头”(无gui)浏览器。 Check out this answer. 看看这个答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM