Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
22a4e81b
Commit
22a4e81b
authored
Nov 22, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8609825e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
CrawlerController.php
console/controllers/CrawlerController.php
+38
-2
No files found.
console/controllers/CrawlerController.php
View file @
22a4e81b
...
...
@@ -7,6 +7,7 @@
*/
namespace
console\controllers
;
use
common\models\psources\Coin
;
use
yii\console\Controller
;
...
...
@@ -15,14 +16,48 @@ class CrawlerController extends Controller
public
function
actionCoinInfo
()
{
$feixiaohao_url
=
"https://www.feixiaohao.com/currencies/vechain"
;
$sidItems
=
array_column
(
Coin
::
find
()
->
select
(
'sid'
)
->
asArray
()
->
all
(),
'sid'
);
foreach
(
$sidItems
as
$sid
){
if
(
$sid
){
$coinInfo
=
Coin
::
find
()
->
where
([
'sid'
=>
$sid
])
->
one
();
$release
=
$this
->
getReleaseTime
(
$sid
);
$isDate
=
$this
->
isDateTime
(
$release
);
if
(
!
$isDate
){
$release
=
''
;
}
$coinInfo
->
release
=
$release
;
$coinInfo
->
save
();
echo
'币种名称: '
.
$coinInfo
->
name
.
'--'
.
$coinInfo
->
nickname
.
'--sid: '
.
$sid
.
PHP_EOL
;
echo
'发行时间: '
.
$release
.
' 更新成功'
.
PHP_EOL
;
}
}
}
private
function
getReleaseTime
(
$sid
)
{
try
{
$feixiaohao_url
=
"https://www.feixiaohao.com/currencies/"
.
$sid
;
$content
=
file_get_contents
(
$feixiaohao_url
);
//preg_match 只匹配一次就返回
$patt
=
"/<li><span class=tit>发行时间:<\/span> <span class=value>(.+?)<\/span><li>/"
;
preg_match
(
$patt
,
$content
,
$res
);
var_dump
(
$res
);
$release_time
=
$res
[
1
];
return
$release_time
;
}
catch
(
\Exception
$e
){
echo
$sid
.
'-----非小号上不存在'
;
return
''
;
}
}
private
function
isDateTime
(
$dateTime
){
$ret
=
strtotime
(
$dateTime
);
return
$ret
!==
FALSE
&&
$ret
!=
-
1
;
}
}
\ No newline at end of file
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