当前位置:网站首页>Phantomjs实用代码段(持续更新中……)
Phantomjs实用代码段(持续更新中……)
2022-06-22 20:43:00 【马克社区】
一、下载
下载链接 二、解压安装包
直接解压即可 三、配置环境变量
找到高级系统设置,打开它,出现以下图。点击环境变量。
分别点击编辑按钮
分别新建添加当初的解压路径,到bin文件夹。点击确定。
这样,环境变量配置好了,可以再命令行工具直接使用phantomjs命令。 四、代码段
新建一个JS文件,如:main.js
执行命令:phantomjs main.js1、打印指定网址标题
var page = require(‘webpage’).create(); phantom.outputEncoding=“gbk”; page.open(“https://url.163.com/EWS”, function(status) { console.log("Status: " + status); if ( status === “success” ) { console.log(page.title) } else { console.log(“Page failed to load.”); } phantom.exit(0); });
2、生成网页截图
var page = require(‘webpage’).create(); page.open(‘https://maomin.blog.csdn.net/’, function() { page.render(‘github.png’); phantom.exit(); });
3、将网页转换为PDF
更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119906672
边栏推荐
- 组合总数[标准回溯 + 回溯技巧--降低栈深度]
- Makefile:1860: recipe for target ‘cmake_ check_ build_ system‘ failed make: *** [cmake_check_build_syst
- Plan and change of continuous repair
- NFT can only be viewed from afar, but not blatantly played
- 2020-12-04
- Reinforcement learning weekly (issue 50): saferl kit, gmi-drl, rp-sdrl & offline meta reinforcement learning
- LinkedList 源码解析
- Uninstall mavros
- Case 2 of SQL performance degradation caused by modifying implicit parameters
- 2021-03-06
猜你喜欢

Grafana report display of sentinel based high availability current limiting system

Summary of just meal with 900W increase in playback and acclaim from station B users

There are 15 necessary knowledge points for the second level cost engineer before the exam! I wish you success!

The required reading for candidates | PMP the test on June 25 is approaching. What should we pay attention to?

What are the methods of software stress testing and how to select a software stress testing organization?

Technology cloud report: East to West computing is not only about "computing", but also needs "new storage"

Experiment 4 operation comparison between NoSQL and relational database

2021-04-14

2021-04-14

新捷途X70S上市8.79万起,空间安全越级,不愧是网红国民大7座SUV
随机推荐
[Li mu] how to read papers [intensive reading of papers]
volume rendering
2020-12-20
【ROS】ROSmsg cakin_make编译错误
Task management of embedded development foundation (thread management)
2020-12-20
redis 报错解决与常用配置
What are the methods of software stress testing and how to select a software stress testing organization?
Redis error reporting and common configurations
《强化学习周刊》第50期:SafeRL-Kit、GMI-DRL、RP-SDRL & 离线元强化学习
欧洲的龙之城|国家地理全球最浪漫最安全的目的地
MySQL multi table operation exercise
Redis-分布式锁
Lua-- use of data types, variables, loops, functions and operators
Task cache compilation caused by gradle build cache
Total number of combinations [standard backtracking + backtracking techniques -- reducing stack depth]
5分钟快速上线Web应用和API(Vercel)
Valid parentheses
Reinforcement learning weekly (issue 50): saferl kit, gmi-drl, rp-sdrl & offline meta reinforcement learning
Explain the startup process of opengauss multithreading architecture in detail