手册
目录
收藏527
分享
阅读23618
更新时间2022-04-11
DImage扩展,可实现简单的图片下载需求。
安装:
composer require jaeger/querylist-ext-dimage
GIT地址:
https://github.com/jae-jae/QueryList-Ext-DImage
DImage扩展依赖Http类,Git地址为:https://github.com/jae-jae/Http.git
手动安装插件教程:http://doc.querylist.cc/site/index/doc/7
file_get_contents('http://xxx.com/1.html'),
//图片保存路径(相对于网站跟目录),可选,默认:/images
'image_path' => '/xx/x/',
//网站根目录全路径,如:/var/www/html
'www_root' => dirname(__FILE__),
//补全HTML中的图片路径,可选,默认为空
'base_url' => 'http://uploads.rayli.com.cn',
//图片链接所在的img属性,可选,默认src
//多个值的时候用数组表示,越靠前的属性优先级越高
'attr' => array('data-src','src'),
//单个值时可直接用字符串
//'attr' => 'data-src',
//回调函数,用于对图片的额外处理,可选,参数为img的phpQuery对象
'callback' => function($imgObj){
$imgObj->attr('alt','xxx');
$imgObj->removeAttr('class');
//......
}
]);
print_r($html);$url = 'http://cms.querylist.cc/news/it/547.html';
$reg = [
'title' => array('h1','text'),
'content' => array('.post_content','html')
];
$data = QueryList::Query($url,$reg,'.content')->getData(function($item){
//图片本地化
$item['content'] = QueryList::run('DImage',[
'content' => $item['content'],
'image_path' => '/img/'.date('Y-m-d'),
'www_root' => dirname(__FILE__)
]);
return $item;
});
print_r($data);
STR; $html = QueryList::run('DImage',[ 'content' => $con, 'www_root' => dirname(__FILE__), 'base_url' => 'http://x.44i.cc', 'attr' => array('data-original','src'), 'image_path' => '/xx', 'callback' => function($o){ $o->attr('alt','111'); $o->removeAttr('class'); } ]); echo $html; /** 输出:
**/
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
70.9万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125万人学习