Linux环境phantomjs安装,使用,常见问题

Linux安装Phantomjs

我之前写过一篇《SptingBoot基于Echarts生成折线图,柱状图》的文章,不过是基于windows环境的使用与运行的,那Linux环境应该怎么使用Phantomjs呢?

安装

  • PhantomJS(官方下载) 该超链接为官方下载地址,我们可以根据自己的环境,下载所需的版本或者最新的版本 或者直接在Linux运行
  • wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 】下载Linux64的压缩包在这里插入图片描述
  • 下载完成后在压缩包所在文件夹下进行解压到当前文件夹下
 tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2 

在这里插入图片描述

  • 解压完成过,我们进入…/phantomjs-2.1.1-linux-x86_64/bin/文件夹中,将phantomjs执行文件放入/use/bin文件夹下,相当于我们在windows中配置环境变量,从而方便我们运行
sudo ln -s /phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
  • 完成后,我们进行输入命令 phantomjs -h 如果你发现报错了 (没有报错请跳过)
root@ai:/home/ai# phantomjs -h
Auto configuration failed
140454038030272:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory
140454038030272:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
140454038030272:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=providers, path=providers
140454038030272:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=providers

这个问题是因为Ubuntu 22.04 使用新的 OpenSSL 版本 3.0.2 而不是旧的 OpenSSL 版本 1.1.1 。这些 OpenSSL 版本不完全向后兼容,所以这就是为什么您在 PhantomJS 尝试自动配置 SSL/TLS 设置时看到此错误的原因。

 export OPENSSL_CONF=/dev/null

再次运行phantomjs -h,就恢复正常

root@ai:/home/ai# phantomjs -h
Usage:
   phantomjs [switchs] [options] [script] [argument [argument [...]]]

Options:
  --cookies-file=<val>                 Sets the file name to store the persistent cookies
  --config=<val>                       Specifies JSON-formatted configuration file
  --debug=<val>                        Prints additional warning and debug message: 'true' or 'false' (default)
  --disk-cache=<val>                   Enables disk cache: 'true' or 'false' (default)
  --disk-cache-path=<val>              Specifies the location for the disk cache
  。。。。。

  • 接下来我们运行phantomjs /phantomjs-2.1.1-linux-x86_64/examples/hello.js
root@ai:/# phantomjs /phantomjs-2.1.1-linux-x86_64/examples/hello.js
Hello, world!

输出Hello, world!代表phantomjs 安装成功


使用可参考:《 ptingBoot基于Echarts生成折线图,柱状图,超详细~~》

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
PhantomJS是一个基于Webkit的无界面浏览器,在Linux环境使用PhantomJS可以实现一些自动化的任务,比如网页截图、网页加载、性能测试等。安装PhantomJSLinux环境下可以按照以下步骤进行操作: 1. 下载PhantomJS的压缩包。可以在官方网站上下载所需的版本,比如使用命令`wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2`下载Linux64位的压缩包。 2. 解压下载的压缩包。在压缩包所在的文件夹下,使用命令`tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2`进行解压。 3. 运行PhantomJS。可以使用命令`phantomjs [switchs] [options] [script] [argument [argument [...]]]`来运行PhantomJS。例如,使用`phantomjs -h`可以查看帮助信息,使用`phantomjs /phantomjs-2.1.1-linux-x86_64/examples/hello.js`可以运行一个示例脚本。 通过以上步骤,你就可以在Linux环境安装使用PhantomJS了。请根据你的实际需求和环境进行相应的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Linux安装Phantomjs](https://blog.csdn.net/qq_45273160/article/details/121835052)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Linux环境phantomjs安装使用常见问题](https://blog.csdn.net/qq1328585964/article/details/127691433)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值