【问题标题】:Make GET request, run script on requested page, and return new HTML发出 GET 请求,在请求的页面上运行脚本,并返回新的 HTML
【发布时间】:2017-05-29 10:43:27
【问题描述】:

我需要一种使用 NodeJS 向 url 发出请求、在该页面上运行一些 Javascript 并返回 Javascript 执行后生成的 HTML 的方法。我该怎么做?

例如:

获取http://SiteToRequest.com

http://SiteToRequest.com上运行clickThis(); clickThat(); setAttribute();

然后return JS 运行后抓取的 HTML

【问题讨论】:

    标签: javascript html node.js get httprequest


    【解决方案1】:

    Node.js 本身不提供浏览器运行时环境,但有 phantomjs(以及 node.js 的 phantom-node 集成包)提供。还有http://zombie.js.org/,但我没有经验。

    查看can phantomjs work with node.js? phantom-node 的维护者解释如何使用它

    【讨论】:

      猜你喜欢
      • 2020-07-18
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多