可以执行JavaScript的服务器端浏览器

时间:2022-04-22 16:01:30

Is there any programming libraries available that will parse an HTML document, execute JavaScript and then allow me to navigate the DOM?  This needs to be performed server side, not client side. Any language will do, but Java, PHP, or Ruby are preferred.

是否有任何编程库可以解析HTML文档,执行JavaScript然后允许我导航DOM?这需要在服务器端执行,而不是在客户端执行。任何语言都可以,但Java,PHP或Ruby是首选。

9 个解决方案

#1


2  

in java: http://lobobrowser.org/cobra/java-html-parser.jsp
this is a a Javascript-aware, CSS-aware HTML parser
the most important feature in relation to your question: It is Javascript-aware. DOM modifications that occur during parsing will be reflected in the resulting DOM.

在java中:http://lobobrowser.org/cobra/java-html-parser.jsp这是一个支持Javascript的CSS识别HTML解析器,与您的问题相关的最重要的特性:它是Javascript感知的。解析期间发生的DOM修改将反映在生成的DOM中。

#2


6  

Have you tried Bringing the Browser to the Server?

您是否尝试过将浏览器引入服务器?

#3


2  

Java has support for javascript with Rhino, also look at this page for server side javascript solutions: http://en.wikipedia.org/wiki/Server-side_JavaScript

Java支持使用Rhino的javascript,同时查看服务器端javascript解决方案的这个页面:http://en.wikipedia.org/wiki/Server-side_JavaScript

#4


1  

For Java, be sure to check out HtmlUnit and HttpUnit.

对于Java,请务必查看HtmlUnit和HttpUnit。

#5


1  

PhantomJS does this and can be used with any server side language. See some integration modules below for NodeJS and PHP

PhantomJS执行此操作,可以与任何服务器端语言一起使用。请参阅下面的NodeJS和PHP的一些集成模块

NodeJS

https://npmjs.org/package/node-phantom

https://github.com/sgentle/phantomjs-node

PHP

https://github.com/diggin/php-PhantomjsRunner

#6


0  

PHP has DOMDocument for navigating the DOM. I haven't heard of anything for executing JavaScript.

PHP有DOMDocument用于导航DOM。我还没有听说过执行JavaScript的任何事情。

#7


0  

Start from this post and follow a links. Or just search for Rhino.

从这篇文章开始,然后点击链接。或者只是搜索Rhino。

#8


0  

There are now several projects that do a really good job of this:

现在有几个项目可以很好地完成这项工作:

  • PhantomJS is a headless version of WebKit, and there are some helpful wrappers such as CasperJS.

    PhantomJS是WebKit的无头版本,并且有一些有用的包装器,如CasperJS。

  • Zombie.js which is a wrapper over jsdom written in Javascript (Node.js).

    Zombie.js是用Javascript(Node.js)编写的jsdom包装器。

You need to write JavaScript code to interact with both of these projects. I like Zombie.js better so far, since it is easier to set up, and you can use any Node.js/npm modules in your code.

您需要编写JavaScript代码才能与这两个项目进行交互。到目前为止,我更喜欢Zombie.js,因为它更容易设置,并且您可以在代码中使用任何Node.js / npm模块。

#9


0  

node.js ?

Node can run any javascript file in its console. I would try node first & see if it can do what you want as it likely has the largest user base & documentation.

Node可以在其控制台中运行任何javascript文件。我会首先尝试节点,看看它是否可以做你想要的,因为它可能拥有最大的用户群和文档。

#1


2  

in java: http://lobobrowser.org/cobra/java-html-parser.jsp
this is a a Javascript-aware, CSS-aware HTML parser
the most important feature in relation to your question: It is Javascript-aware. DOM modifications that occur during parsing will be reflected in the resulting DOM.

在java中:http://lobobrowser.org/cobra/java-html-parser.jsp这是一个支持Javascript的CSS识别HTML解析器,与您的问题相关的最重要的特性:它是Javascript感知的。解析期间发生的DOM修改将反映在生成的DOM中。

#2


6  

Have you tried Bringing the Browser to the Server?

您是否尝试过将浏览器引入服务器?

#3


2  

Java has support for javascript with Rhino, also look at this page for server side javascript solutions: http://en.wikipedia.org/wiki/Server-side_JavaScript

Java支持使用Rhino的javascript,同时查看服务器端javascript解决方案的这个页面:http://en.wikipedia.org/wiki/Server-side_JavaScript

#4


1  

For Java, be sure to check out HtmlUnit and HttpUnit.

对于Java,请务必查看HtmlUnit和HttpUnit。

#5


1  

PhantomJS does this and can be used with any server side language. See some integration modules below for NodeJS and PHP

PhantomJS执行此操作,可以与任何服务器端语言一起使用。请参阅下面的NodeJS和PHP的一些集成模块

NodeJS

https://npmjs.org/package/node-phantom

https://github.com/sgentle/phantomjs-node

PHP

https://github.com/diggin/php-PhantomjsRunner

#6


0  

PHP has DOMDocument for navigating the DOM. I haven't heard of anything for executing JavaScript.

PHP有DOMDocument用于导航DOM。我还没有听说过执行JavaScript的任何事情。

#7


0  

Start from this post and follow a links. Or just search for Rhino.

从这篇文章开始,然后点击链接。或者只是搜索Rhino。

#8


0  

There are now several projects that do a really good job of this:

现在有几个项目可以很好地完成这项工作:

  • PhantomJS is a headless version of WebKit, and there are some helpful wrappers such as CasperJS.

    PhantomJS是WebKit的无头版本,并且有一些有用的包装器,如CasperJS。

  • Zombie.js which is a wrapper over jsdom written in Javascript (Node.js).

    Zombie.js是用Javascript(Node.js)编写的jsdom包装器。

You need to write JavaScript code to interact with both of these projects. I like Zombie.js better so far, since it is easier to set up, and you can use any Node.js/npm modules in your code.

您需要编写JavaScript代码才能与这两个项目进行交互。到目前为止,我更喜欢Zombie.js,因为它更容易设置,并且您可以在代码中使用任何Node.js / npm模块。

#9


0  

node.js ?

Node can run any javascript file in its console. I would try node first & see if it can do what you want as it likely has the largest user base & documentation.

Node可以在其控制台中运行任何javascript文件。我会首先尝试节点,看看它是否可以做你想要的,因为它可能拥有最大的用户群和文档。