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
45fa6c80
Commit
45fa6c80
authored
Jul 09, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口数据格式修改
parent
24a108c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
+29
-29
CoinBusiness.php
common/business/CoinBusiness.php
+1
-1
CoinService.php
common/service/coin/CoinService.php
+28
-28
No files found.
common/business/CoinBusiness.php
View file @
45fa6c80
...
@@ -147,7 +147,7 @@ class CoinBusiness
...
@@ -147,7 +147,7 @@ class CoinBusiness
}
}
$coin
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$row
[
'quotation'
]
=
$coin
->
quotation
();
$row
[
'quotation'
]
=
$coin
->
quotation
();
$row
[
'exchange
'
]
=
$coin
->
exchange
();
$row
[
'exchange
_count'
]
=
$coin
->
exchange_count
();
$coin
->
__destruct
();
$coin
->
__destruct
();
}
}
return
$row
?
[
$row
]
:
[];
return
$row
?
[
$row
]
:
[];
...
...
common/service/coin/CoinService.php
View file @
45fa6c80
...
@@ -508,46 +508,46 @@ class CoinService extends Coin implements CoinInterface
...
@@ -508,46 +508,46 @@ class CoinService extends Coin implements CoinInterface
try
{
try
{
$content
=
$ch
->
get
(
$url
,
true
);
$content
=
$ch
->
get
(
$url
,
true
);
$result
=
[
$result
=
[
'price'
=>
''
,
//价格
'price'
=>
''
,
//价格
'dollar'
=>
''
,
//价格美元
'dollar'
=>
''
,
//价格美元
'btc'
=>
''
,
//价格btc
//
'btc' => '',//价格btc
'high'
=>
''
,
//最高价
//
'high' => '',//最高价
'low'
=>
''
,
//最低价
//
'low' => '',//最低价
'change'
=>
''
,
//涨幅(跌幅)
//
'change' => '',//涨幅(跌幅)
'rank'
=>
''
,
//流通市值排名
//
'rank' => '',//流通市值排名
'circulate_value_rmb'
=>
''
,
//流通市值人民币
//
'circulate_value_rmb' => '',//流通市值人民币
'circulate_value_usd'
=>
''
,
//流通市值美元
//
'circulate_value_usd' => '',//流通市值美元
'circulate_value_btc'
=>
''
,
//流通市值btc
//
'circulate_value_btc' => '',//流通市值btc
'publish_count'
=>
''
,
//发行总量
'publish_count'
=>
''
,
//发行总量
'circulate_count'
=>
''
,
//流通总量
'circulate_count'
=>
''
,
//流通总量
];
];
//价格与涨幅
//价格与涨幅
$pattern
=
'/<div class=coinprice>(.*?)<span class=(tags-red|tags-green)>(.*?)<\/span><\/div>/is'
;
$pattern
=
'/<div class=coinprice>(.*?)<span class=(tags-red|tags-green)>(.*?)<\/span><\/div>/is'
;
preg_match_all
(
$pattern
,
$content
,
$matchs
,
PREG_SET_ORDER
);
preg_match_all
(
$pattern
,
$content
,
$matchs
,
PREG_SET_ORDER
);
$result
[
'price'
]
=
$matchs
[
0
][
1
]
;
$result
[
'price'
]
=
sprintf
(
"%0.2f"
,
(
float
)
str_replace
([
'¥'
],
''
,
$matchs
[
0
][
1
]))
;
$result
[
'change'
]
=
$matchs
[
0
][
3
];
//
$result['change'] = $matchs[0][3];
//最高最低值
//最高最低值
preg_match_all
(
'/<div class=lowHeight>(.*?)<\/div><div class=sub>/is'
,
$content
,
$matchs
);
//
preg_match_all('/<div class=lowHeight>(.*?)<\/div><div class=sub>/is', $content, $matchs);
preg_match_all
(
'/<span class=value>(.*?)<\/span>/is'
,
$matchs
[
1
][
0
],
$matchs
);
//
preg_match_all('/<span class=value>(.*?)<\/span>/is', $matchs[1][0], $matchs);
$result
[
'high'
]
=
$matchs
[
1
][
0
];
//
$result['high'] = $matchs[1][0];
$result
[
'low'
]
=
$matchs
[
1
][
1
];
//
$result['low'] = $matchs[1][1];
//美元 btc
//美元 btc
preg_match_all
(
'/<div class=sub><span>(.*?)<\/span>(.*?)<span>(.*?)<\/span><\/div>/is'
,
$content
,
preg_match_all
(
'/<div class=sub><span>(.*?)<\/span>(.*?)<span>(.*?)<\/span><\/div>/is'
,
$content
,
$matchs
,
$matchs
,
PREG_SET_ORDER
);
PREG_SET_ORDER
);
$result
[
'dollar'
]
=
$matchs
[
0
][
1
]
;
$result
[
'dollar'
]
=
sprintf
(
"%0.4f"
,
(
double
)
str_replace
([
'$'
,
'≈'
],
''
,
$matchs
[
0
][
1
]))
;
$result
[
'btc'
]
=
$matchs
[
0
][
3
];
//
$result['btc'] = $matchs[0][3];
//爬取市值与排名
//
//爬取市值与排名
$pattern
=
'/<div class=value>(.*?)<span class=tag-marketcap>(.*?)<\/span><\/div><div class=sub>(.*?)<\/div><div class=sub>(.*?)<\/div>/is'
;
//
$pattern = '/<div class=value>(.*?)<span class=tag-marketcap>(.*?)<\/span><\/div><div class=sub>(.*?)<\/div><div class=sub>(.*?)<\/div>/is';
preg_match_all
(
$pattern
,
$content
,
$matches
,
PREG_SET_ORDER
);
//
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
$result
[
'circulate_value_rmb'
]
=
$matches
[
0
][
1
];
//
$result['circulate_value_rmb'] = $matches[0][1];
$result
[
'rank'
]
=
$matches
[
0
][
2
];
//
$result['rank'] = $matches[0][2];
$result
[
'circulate_value_usd'
]
=
$matches
[
0
][
3
];
//
$result['circulate_value_usd'] = $matches[0][3];
$result
[
'circulate_value_btc'
]
=
$matches
[
0
][
4
];
//
$result['circulate_value_btc'] = $matches[0][4];
//爬取流通总量,发行总量
//爬取流通总量,发行总量
$pattern
=
'/<div class=tit>流通量<\/div><div class=value>(.*?)<\/div><div class=tit>总发行量<\/div><div class=value>(.*?)<\/div>/is'
;
$pattern
=
'/<div class=tit>流通量<\/div><div class=value>(.*?)<\/div><div class=tit>总发行量<\/div><div class=value>(.*?)<\/div>/is'
;
...
...
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