Commit 697ccda1 authored by ZhuChunYang's avatar ZhuChunYang

update

parent 70fb25d5
......@@ -29,7 +29,7 @@ class CoinBusiness
public static function getList($page = 1, $limit = 10, $condition = [])
{
$rows = Coin::getList($page, $limit, $condition);
if ($rows['count'] > 0) {
/* if ($rows['count'] > 0) {
$datas = $rows['data'];
foreach ($datas as $key => $value) {
//获取交易所信息
......@@ -41,7 +41,7 @@ class CoinBusiness
$rows['data'][$key]['exchange'] = 0;
}
}
}
}*/
return $rows;
}
......@@ -55,7 +55,7 @@ class CoinBusiness
public static function getRecommendList($page = 1, $limit = 10, $condition = [])
{
$rows = Coin::getRecommendList($page, $limit, $condition);
if ($rows['count'] > 0) {
/* if ($rows['count'] > 0) {
$datas = $rows['data'];
foreach ($datas as $key => $value) {
//获取交易所信息
......@@ -67,7 +67,7 @@ class CoinBusiness
$rows['data'][$key]['exchange'] = 0;
}
}
}
}*/
return $rows;
}
......
......@@ -14,7 +14,8 @@ use yii\console\Controller;
class CrawlerController extends Controller
{
public function actionCoinInfo()
//更新发行时间
public function actionCoinReleaseTime()
{
$sidItems = array_column(Coin::find()->select('sid')->asArray()->all(),'sid');
......@@ -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)
{
try{
......@@ -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){
$ret = strtotime($dateTime);
return $ret !== FALSE && $ret != -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment