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
697ccda1
Commit
697ccda1
authored
Nov 23, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
70fb25d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
CoinBusiness.php
common/business/CoinBusiness.php
+4
-4
CrawlerController.php
console/controllers/CrawlerController.php
+36
-1
No files found.
common/business/CoinBusiness.php
View file @
697ccda1
...
@@ -29,7 +29,7 @@ class CoinBusiness
...
@@ -29,7 +29,7 @@ class CoinBusiness
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
{
$rows
=
Coin
::
getList
(
$page
,
$limit
,
$condition
);
$rows
=
Coin
::
getList
(
$page
,
$limit
,
$condition
);
if
(
$rows
[
'count'
]
>
0
)
{
/*
if ($rows['count'] > 0) {
$datas = $rows['data'];
$datas = $rows['data'];
foreach ($datas as $key => $value) {
foreach ($datas as $key => $value) {
//获取交易所信息
//获取交易所信息
...
@@ -41,7 +41,7 @@ class CoinBusiness
...
@@ -41,7 +41,7 @@ class CoinBusiness
$rows['data'][$key]['exchange'] = 0;
$rows['data'][$key]['exchange'] = 0;
}
}
}
}
}
}
*/
return
$rows
;
return
$rows
;
}
}
...
@@ -55,7 +55,7 @@ class CoinBusiness
...
@@ -55,7 +55,7 @@ class CoinBusiness
public
static
function
getRecommendList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
public
static
function
getRecommendList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
{
$rows
=
Coin
::
getRecommendList
(
$page
,
$limit
,
$condition
);
$rows
=
Coin
::
getRecommendList
(
$page
,
$limit
,
$condition
);
if
(
$rows
[
'count'
]
>
0
)
{
/*
if ($rows['count'] > 0) {
$datas = $rows['data'];
$datas = $rows['data'];
foreach ($datas as $key => $value) {
foreach ($datas as $key => $value) {
//获取交易所信息
//获取交易所信息
...
@@ -67,7 +67,7 @@ class CoinBusiness
...
@@ -67,7 +67,7 @@ class CoinBusiness
$rows['data'][$key]['exchange'] = 0;
$rows['data'][$key]['exchange'] = 0;
}
}
}
}
}
}
*/
return
$rows
;
return
$rows
;
}
}
...
...
console/controllers/CrawlerController.php
View file @
697ccda1
...
@@ -14,7 +14,8 @@ use yii\console\Controller;
...
@@ -14,7 +14,8 @@ use yii\console\Controller;
class
CrawlerController
extends
Controller
class
CrawlerController
extends
Controller
{
{
public
function
actionCoinInfo
()
//更新发行时间
public
function
actionCoinReleaseTime
()
{
{
$sidItems
=
array_column
(
Coin
::
find
()
->
select
(
'sid'
)
->
asArray
()
->
all
(),
'sid'
);
$sidItems
=
array_column
(
Coin
::
find
()
->
select
(
'sid'
)
->
asArray
()
->
all
(),
'sid'
);
...
@@ -35,6 +36,24 @@ class CrawlerController extends Controller
...
@@ -35,6 +36,24 @@ class CrawlerController extends Controller
}
}
//更新上架交易所
public
function
actionCoinExchanges
()
{
$sidItems
=
array_column
(
Coin
::
find
()
->
select
(
'sid'
)
->
asArray
()
->
all
(),
'sid'
);
foreach
(
$sidItems
as
$sid
){
if
(
$sid
){
$coinInfo
=
Coin
::
find
()
->
where
([
'sid'
=>
$sid
])
->
one
();
$exchange
=
$this
->
getExchange
(
$sid
);
$coinInfo
->
exchange
=
$exchange
;
$coinInfo
->
save
();
echo
'币种名称: '
.
$coinInfo
->
name
.
'--'
.
$coinInfo
->
nickname
.
'--sid: '
.
$sid
.
PHP_EOL
;
echo
'上架交易所数量: '
.
$exchange
.
' 更新成功'
.
PHP_EOL
;
}
}
}
private
function
getReleaseTime
(
$sid
)
private
function
getReleaseTime
(
$sid
)
{
{
try
{
try
{
...
@@ -52,6 +71,22 @@ class CrawlerController extends Controller
...
@@ -52,6 +71,22 @@ class CrawlerController extends Controller
}
}
private
function
getExchange
(
$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> <a href=#tickerlist> (\d+)家 <\/a> <\/span><li>/"
;
preg_match
(
$patt
,
$content
,
$res
);
$exchange
=
$res
[
1
];
return
$exchange
;
}
catch
(
\Exception
$e
){
echo
$sid
.
'-----非小号上不存在'
;
return
0
;
}
}
private
function
isDateTime
(
$dateTime
){
private
function
isDateTime
(
$dateTime
){
$ret
=
strtotime
(
$dateTime
);
$ret
=
strtotime
(
$dateTime
);
return
$ret
!==
FALSE
&&
$ret
!=
-
1
;
return
$ret
!==
FALSE
&&
$ret
!=
-
1
;
...
...
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