Commit 87c90f89 by 杨树贤

完全部分逻辑

parent b28f4ea9
......@@ -660,4 +660,6 @@ class DataService
})->export('csv');
}
}
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\SupplierBlacklistModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
//处理多个系统的图片替换问题
class DealImageService
{
public static function getAllImage($text)
{
$pattern = '/<img [^>]*src\s*=\s*["\']?([^"\'>]*img\.ichunt\.com[^"\'>]*)/i';
preg_match_all($pattern, $text, $matches);
$imageUrls = $matches[1];
dump($imageUrls); // 输出所有提取出的 'img.ichunt.com' 图片链接
}
//先去处理芯媒体的图片链接
public static function dealNewsImage()
{
$newsList = DB::connection('liexin')->table('article_addon')->limit(10)->get();
foreach ($newsList as $news) {
self::getAllImage($news['body']);
}
}
//根据url下载图片并且上传到图片服务
public static function downloadAndUploadToPicServer($url)
{
$path = storage_path('/dealImage/') . md5($url);
$client = new \GuzzleHttp\Client();
$response = $client->get($url);
$contents = $response->getBody()->getContents();
file_put_contents($path, $contents);
//然后上传到图片服务器
//最后删除本地的文件
unlink($path);
}
}
......@@ -84,7 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
\App\Http\Services\DataService::exportNameInvalid();
\App\Http\Services\DataService::dealNewsImage();
//\App\Http\Services\SupplierAddressService::initUnitedAddress();
//\App\Http\Services\DataService::checkSupplierBandAccount();
//(new CompanyService())->checkSupplierCompanyAndAddress(11042);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment