Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
213d3c50
Commit
213d3c50
authored
Apr 26, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
8e6c7836
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
0 deletions
+66
-0
server/app/Console/Commands/CheMenuCommand.php
server/app/Console/Commands/CheMenuCommand.php
+2
-0
server/app/Services/ThirdPlatform/Api/CheMenuApiService.php
server/app/Services/ThirdPlatform/Api/CheMenuApiService.php
+21
-0
server/app/Services/ThirdPlatform/CheMenuService.php
server/app/Services/ThirdPlatform/CheMenuService.php
+43
-0
No files found.
server/app/Console/Commands/CheMenuCommand.php
View file @
213d3c50
...
@@ -67,6 +67,8 @@ class CheMenuCommand extends Command
...
@@ -67,6 +67,8 @@ class CheMenuCommand extends Command
break
;
break
;
case
'product'
:
case
'product'
:
$service
->
productPage
(
$params
);
$service
->
productPage
(
$params
);
case
'updateCategoryDesc'
:
$service
->
updateAllCategoryDesc
(
$params
);
default
:
default
:
}
}
}
}
...
...
server/app/Services/ThirdPlatform/Api/CheMenuApiService.php
View file @
213d3c50
...
@@ -56,6 +56,27 @@ class CheMenuApiService extends PlatformAbstractService
...
@@ -56,6 +56,27 @@ class CheMenuApiService extends PlatformAbstractService
}
}
}
}
public
function
updateCategoryDesc
(
$categoryName
,
$content
)
{
try
{
$response
=
$this
->
getPostClient
(
$this
->
yybaoApiUrl
.
'/webpage/chemenu/updateCategoryDesc'
,
[
'categoryName'
=>
$categoryName
,
'content'
=>
$content
],
[]);
return
$this
->
returnResponse
(
$response
);
}
catch
(
\Throwable
$exception
){
if
(
preg_match
(
'/\{(?<response>[\s\S]*?)\}/i'
,
$exception
->
getMessage
(),
$response
)){
$response
=
json_decode
(
'{'
.
$response
[
'response'
]
.
'}'
,
true
);
if
(
$response
&&
$response
[
'status'
]
==
429
){
sleep
(
60
);
$this
->
updateCategoryDesc
(
$categoryName
,
$content
);
}
}
$this
->
requestError
(
$exception
);
}
}
public
function
saveProduct
(
$productContent
)
public
function
saveProduct
(
$productContent
)
{
{
try
{
try
{
...
...
server/app/Services/ThirdPlatform/CheMenuService.php
View file @
213d3c50
...
@@ -46,6 +46,49 @@ class CheMenuService
...
@@ -46,6 +46,49 @@ class CheMenuService
}
}
}
}
public
function
updateAllCategoryDesc
()
{
$responseHtml
=
$this
->
apiService
->
getAllCatetgory
();
if
(
$responseHtml
){
$categoryDivRegx
=
'/<dt><span[\s]*?style=[\\\'|\"][\s\S]+?[\\\'|\"]>(?<categoryH1>[\s\S]+?)<\/span>[\s\S]*?<dd>(?<category>[\s\S]+?)<\/dd>/i'
;
preg_match_all
(
$categoryDivRegx
,
$responseHtml
,
$categoryHtml
);
if
(
$categoryHtml
){
foreach
(
$categoryHtml
[
'categoryH1'
]
as
$key
=>
$h1
){
if
(
!
empty
(
$categoryHtml
[
'category'
][
$key
])){
preg_match_all
(
'/<a[\s]*?href=[\\\'|\"](?<href>[\s\S]+?)[\\\'|\"]>(?<categoryName>[\s\S]+?)<\/a>/i'
,
$categoryHtml
[
'category'
][
$key
],
$categoryList
);
if
(
!
empty
(
$categoryList
)){
foreach
(
$categoryList
[
'categoryName'
]
as
$k
=>
$category
){
$pageUrl
=
$categoryList
[
'href'
][
$k
];
$responseHtml
=
$this
->
apiService
->
getPage
(
$pageUrl
);
if
(
$responseHtml
){
if
(
preg_match
(
'/<span[\s]*?class=[\\\'|\"]caption-subject font-blue-sharp bold[\\\'|\"]>Sorry ! You visit too frequently, please complete validation[\s\S]*?<\/span><\/h2>/i'
,
$responseHtml
)){
SimpleLogs
::
writeLog
(
'遇到反爬系统'
,
'chemenu info'
,
'info'
);
$jobContent
=
[
'params'
=>
[
'url'
=>
$pageUrl
],
'consumer'
=>
__CLASS__
,
'method'
=>
'categoryPage'
];
$this
->
apiService
->
pushQueue
(
$jobContent
,
'chemenu_category_page'
);
break
;
}
SimpleLogs
::
writeLog
(
'开始分析分类页面数据'
,
'chemenu info'
,
'info'
);
$titleDivRegx
=
'/<div[\s]*?class=[\\\'|\"]cate_desc[\\\'|\"]>[\S\s]*<h2[\s]*?class=[\\\'|\"]desc_title[\\\'|\"]>(?<title>[\s\S]+?)<\/h2>[\s\S]*?<p[\s]*?class=[\\\'|\"]desc_content[\\\'|\"]>(?<content>[\s\S]*?)<\/p>/i'
;
preg_match
(
$titleDivRegx
,
$responseHtml
,
$titleHtml
);
if
(
$titleHtml
){
$this
->
apiService
->
updateCategoryDesc
(
$category
,
$titleHtml
[
'content'
]);
}
}
}
}
}
sleep
(
60
);
}
}
return
true
;
}
}
public
function
categoryPage
(
$url
)
public
function
categoryPage
(
$url
)
{
{
try
{
try
{
...
...
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