ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
1. 内容详情图片的采集 如下图 images 方法 2. 下载图片采集工具, 八爪鱼采集器插件 [https://www.bazhuayu.com/tutorial/tupiancaiji](https://www.bazhuayu.com/tutorial/tupiancaiji) 将数据image 导出excel , 然后 按照图片采集模板 excel 编写, 通过采集工具采集图片到本地 ~~~ public function images() { ini_set("max_execution_time", "0"); $select = Db::name('product')->field(['url', 'id', 'title', 'content'])->order('id asc')->select(); $new_image = []; //获取内容详情的图片 foreach ($select as $value) { $data = QueryList::html($value['content'])->rules(array( 'image' => array('img', 'src') ))->query()->getData(function ($item) { return $item; }); $all_image = $data->all(); if (!$all_image) { continue; } foreach ($all_image as $value1) { //判断内容详情的图片是否是绝对地址 if (strpos($value1['image'], 'http') === false) { $new_image[] = $value1['image']; } else { //如果是绝对地址则转换成相对地址,并且将内容详情的图片地址改成相对地址 if (strpos($value1['image'], 'uhomework')) { $new_image[] = $value1['image']; $value['content'] = str_replace('https://uhomework.com/', '/', $value['content']); Db::name('product')->where([['id', '=', $value['id']]])->update(['content' => $value['content']]); } } } } $arr_image = []; foreach ($new_image as $value) { $result = pathinfo($value); $result['dirname'] = str_replace('https://uhomework.com/', '/', $result['dirname']); $value = str_replace('/', '\\', $value); $arr_image[] = [ //图片名称 'title' => '图片', //图片采集的地址 'image' => 'https://uhomework.com/' . $value, //图片保存的本地路径 'path' => "E:" . $value, ]; } $result = Db::name('image')->insertAll($arr_image); dump($result);exit; } ~~~