html生成图片,html生成长微博,网页生成图片,网页生成长微博
html
圖片
微博
產生
網頁
html生成图片,html生成长微博 更多功能请访问:http://www.dahuzhi.com 安装扩展: (1)下面是我在linux上的安装过程,如果没有安装git请先yuminstallgit 安装casperjs cd/ gitclonegit://github.com/n1k0/casperjs.git cdcasperjs ln-sf/casperjs/bin/casperjs/
html生成图片,html生成长微博
更多功能请访问: http://www.dahuzhi.com
安装扩展:
(1)下面是我在linux上的安装过程,如果没有安装git请先yum install git
安装casperjs
cd /
git clone git://github.com/n1k0/casperjs.git
cd casperjs
ln -sf /casperjs/bin/casperjs /usr/local/bin/casperjs //可以忽略 实际执行中php是执行 /casperjs/bin/casperjs
(2)安装phantomjs,下载地址:http://phantomjs.org/download.html
下载后操作很简单,直接把解压好的\bin\phantomjs移动到\usr\local\bin\phantomjs就可以了。\
测试phantomjs --version 有结果不报错,说明安装OK
(3)安装字体
1. 首先获得一套“微软雅黑”字体库(Google一下一大把),包含两个文件msyh.ttf(普通)、msyhbd.ttf(加粗);
2. 在/usr/share/fonts目录下建立一个子目录,例如win,命令如下:
# mkdir /usr/share/fonts/win
3. 将msyh.ttf和msyhbd.ttf复制到该目录下,例如这两个文件放在/root/Desktop下,使用命令:
# cd /root/Desktop
# cp msyh.ttf msyhbd.ttf /usr/share/fonts/win/
4. 建立字体索引信息,更新字体缓存:
# cd /usr/share/fonts/win
# mkfontscale (如果提示 mkfontscale: command not found,需自行安装 # yum install mkfontscale )
# mkfontdir
# fc-cache (如果提示 fc-cache: command not found,则需要安装# yum install fontconfig )
至此,字体已经安装完毕! CasperJS linux-ntfs PHP
<?php $www = "http://www.dahuzhi.com"; //要生成的网页地址 $name= time().'.png'; //生成的图片名 //定义js文件内容 body就是页面要生成的内容区间 也可以是页面的某个id如: #content $str = <<<ABC var casper = require('casper').create(); if(casper.cli.has(0)){ var id = casper.cli.get(0); //casper.echo(id); casper.start("@www@", function() { this.captureSelector("@name@", 'body'); }); casper.run(); }else{ casper.exit(); } ABC; $str = str_replace(array("@www@","@name@"), array($www,$name), $str); file_put_contents("test.js", $str); //如果不加这句就会报错“Fatal: [Errno 2] No such file or directory; did you install phantomjs?”,详情参考http://mengkang.net/87.html putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); //调试使用下面的代码,会提示权限等各种错误,例如sh: /casperjs/bin/casperjs: Permission denied $handle = popen('/casperjs/bin/casperjs test.js '.$name.' 2>&1','r'); $read = stream_get_contents($handle); echo $read; echo '<img src="/static/imghw/default1.png" data-src="http://'.$_SERVER['HTTP_HOST'].'/'.$name.'" class="lazy".$_SERVER['HTTP_HOST'].'/'.$name.'" alt="html生成图片,html生成长微博,网页生成图片,网页生成长微博" >'; pclose($handle);
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
Windows 11 KB5054979中的新功能以及如何解決更新問題
3 週前
By DDD
如何修復KB5055523無法在Windows 11中安裝?
2 週前
By DDD
Inzoi:如何申請學校和大學
4 週前
By DDD
如何修復KB5055518無法在Windows 10中安裝?
2 週前
By DDD
Roblox:Dead Rails - 如何召喚和擊敗Nikola Tesla
4 週前
By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)