Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
87c90f89
authored
Aug 29, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完全部分逻辑
parent
b28f4ea9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletions
app/Http/Services/DataService.php
app/Http/Services/DealImageService.php
app/Http/routes.php
app/Http/Services/DataService.php
View file @
87c90f89
...
...
@@ -660,4 +660,6 @@ class DataService
})
->
export
(
'csv'
);
}
}
app/Http/Services/DealImageService.php
0 → 100644
View file @
87c90f89
<?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
);
}
}
app/Http/routes.php
View file @
87c90f89
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment