获取浏览器渲染的 html+javascript

2024-03-31

我需要一个命令行工具(或Javascript/PHP,但我认为命令行是唯一的方法)来渲染并获取URL的渲染内容,但重要的是我需要渲染Javascript而不仅仅是CSS/Html/图像。

例如命令如下:“renderenginehttp://www.google.es http://www.google.esoutputfile.html”和网页内容(解析的 html 和执行的 javascript)保存在 outputfile.html 中。

我需要这个,因为我需要获取像groveshark这样的完整javascript网站的结果,该网站全部使用javascript/ajax加载,而爬虫什么也找不到,只有基本的HTML空模板(因为是在使用ajax/javscript之后加载的)

是否存在支持 Javascript(例如 V8)的 Linux 浏览器引擎,可以输出结果并保存在文件中?


  • Selenium http://www.seleniumhq.org:非常完整的解决方案,具有多种语言的绑定
  • 木偶师 https://github.com/GoogleChrome/puppeteer:无头 Chrome API,可在 NodeJS 中使用或作为命令行工具
  • HTtrack https://www.httrack.com:命令行工具
  • 阿帕奇缺口 http://nutch.apache.org & webmagic https://github.com/code4craft/webmagic:开源Java网络爬虫
  • pholcus https://github.com/henrylee2cn/pholcus:用Go编写的“分布式高并发”网络爬虫
  • Xvfb http://semicomplete.com/blog/geekery/xvfb-firefox.html实现 X11 显示服务器协议的显示服务器,不显示任何屏幕输出。我已成功地将它与 Travis CI 和 Protractor 一起使用作为示例。选择:XDummy http://xpra.org/trac/wiki/Xdummy
  • PhantomJS http://phantomjs.org (first suggested by nvuono https://stackoverflow.com/users/87464/nvuono) : can export the rendered page as non-HTML (pdf, png...). PhantomJS development is suspended until further notice (more details https://github.com/ariya/phantomjs/issues/15344). Closely related: SlimerJS http://slimerjs.org, CasperJS http://casperjs.org

Python 网络抓取库有很多:

  • Scrapy http://doc.scrapy.org
  • pyspider https://github.com/binux/pyspider
  • ghost.py https://github.com/jeanphix/Ghost.py
  • splinter https://splinter.readthedocs.io
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

获取浏览器渲染的 html+javascript 的相关文章

随机推荐