Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crawler.vmusicchart.vn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phạm Văn Đoan
crawler.vmusicchart.vn
Commits
ed4c258c
Commit
ed4c258c
authored
Jan 30, 2021
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code thêm đoạn lấy ds bài hát ở yeunhacvang.com
parent
18f26e6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
0 deletions
+131
-0
YnvCommand.php
app/Console/Commands/Ynv/YnvCommand.php
+106
-0
Kernel.php
app/Console/Kernel.php
+2
-0
Ynv.php
app/Models/Ynv/Ynv.php
+23
-0
No files found.
app/Console/Commands/Ynv/YnvCommand.php
0 → 100644
View file @
ed4c258c
<?php
namespace
App\Console\Commands\Ynv
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\DB
;
class
YnvCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'ynv:get-track {page_index?}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Command description'
;
/**
* Create a new command instance.
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$page_index
=
$this
->
argument
(
'page_index'
);
$page_index
=
intval
(
$page_index
);
echo
"
\n
Starting..."
;
$results
=
[];
$domain
=
'http://www.yeunhacvang.com/'
;
//$page_index = 34;
//for ($page = 1; $page <= 140; $page++) {
for
(
$page
=
$page_index
;
$page
<=
$page_index
;
$page
++
)
{
echo
"
\n
- Processing page "
.
$page
;
$title
=
[];
$link
=
[];
$singer
=
[];
$url
=
$domain
.
'?pg=list&page='
.
$page
;
$dom
=
getDom
(
$url
);
/* Lấy tên bài hát */
$element_track_title
=
'div.main table#table1 tr td a'
;
foreach
(
$dom
->
find
(
$element_track_title
)
as
$data
)
{
$title
[]
=
str_replace
([],
[],
$data
->
innertext
);
}
/* Lấy link bài hát */
$element_track_title
=
'div.main table#table1 tr td a'
;
foreach
(
$dom
->
find
(
$element_track_title
)
as
$data
)
{
$link
[]
=
$domain
.
str_replace
([],
[],
$data
->
href
);
}
/* Lấy tên ca sĩ */
$element_track_title
=
'div.main table#table1 tr td'
;
foreach
(
$dom
->
find
(
$element_track_title
)
as
$data
)
{
if
(
$data
->
width
==
"40%"
)
{
$singer
[]
=
str_replace
([],
[],
$data
->
innertext
);
}
}
echo
"
\n
-> Số bài "
.
count
(
$title
);
for
(
$i
=
0
;
$i
<
count
(
$title
);
$i
++
)
{
preg_match
(
"/-([0-9]+)$/"
,
$link
[
$i
],
$ids
);
$results
[]
=
[
'page_index'
=>
$page_index
,
'track_id'
=>
(
is_array
(
$ids
)
&&
count
(
$ids
)
==
2
)
?
$ids
[
1
]
:
null
,
'title'
=>
$title
[
$i
],
'singer'
=>
$singer
[
$i
+
1
],
'detail_link'
=>
$link
[
$i
],
'is_checking'
=>
0
,
'created_at'
=>
Carbon
::
now
(),
'updated_at'
=>
Carbon
::
now
()
];
}
}
//print_r($results);
if
(
count
(
$results
)
>
0
)
{
DB
::
table
(
'ynvs'
)
->
insert
(
$results
);
}
echo
"
\n
Done."
;
}
}
app/Console/Kernel.php
View file @
ed4c258c
...
...
@@ -14,6 +14,7 @@ use App\Console\Commands\Nct\NctCrawlerTrackCommand;
use
App\Console\Commands\NhacVn\NhacVnCrawlerTrackCommand
;
use
App\Console\Commands\SendWarningCommand
;
use
App\Console\Commands\Update\UpdateTrackArtistCommand
;
use
App\Console\Commands\Ynv\YnvCommand
;
use
App\Console\Commands\Zing\ZingCrawlerNewRealeaseCommand
;
use
App\Console\Commands\Zing\ZingCrawlerTrackCommand
;
use
App\Console\Commands\CrawlerTrackImageCommand
;
...
...
@@ -29,6 +30,7 @@ class Kernel extends ConsoleKernel
*/
protected
$commands
=
[
CrontjobCommand
::
class
,
YnvCommand
::
class
,
ZingCrawlerTrackCommand
::
class
,
ZingCrawlerNewRealeaseCommand
::
class
,
...
...
app/Models/Ynv/Ynv.php
0 → 100644
View file @
ed4c258c
<?php
namespace
App\Models\Ynv
;
use
Illuminate\Database\Eloquent\Model
;
class
Ynv
extends
Model
{
protected
$table
=
'ynvs'
;
public
$timestamps
=
true
;
protected
$fillable
=
[
'page_index'
,
'track_id'
,
'title'
,
'singer'
,
'detail_link'
,
'mp3_link'
,
'lyric'
,
'is_checking'
];
}
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