Commit 68b06e20 authored by shajiaiming's avatar shajiaiming

fix

parent 742c3367
......@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_boc';
protected $quotation_prefix = 'quotation_boc_';
protected $base_url = 'http://srh.bankofchina.com/search/whpj/search.jsp';
protected $base_url = 'https://srh.bankofchina.com/search/whpj/search_cn.jsp';
public function symbolExists($tag = 'CNY', $aim = "JPY")
{
......@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface
}
return false;
}
/**
* 转化交易对为请求变量
*
......@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface
*/
public function formatSymbol($tag = 'CNY', $aim = 'JPY')
{
return strtoupper($tag .'_'. $aim);
return strtoupper($tag . '_' . $aim);
}
/**
......@@ -60,13 +61,14 @@ class Boc extends Exchange implements ExchangeInterface
'erectDate' => '',
'nothing' => '',
'pjname' => 1323
])->post('http://srh.bankofchina.com/search/whpj/search.jsp');
])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT',$response);
$response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main'));
foreach ($div->find('td') as $key => $e){
if($key == 5){
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = $this->quotation_prefix . 'CNY_JPY';
$this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext);
$this->redis->sadd($this->supported_symbol, 'CNYJPY');
......@@ -74,5 +76,6 @@ class Boc extends Exchange implements ExchangeInterface
}
}
}
}
}
\ No newline at end of file
......@@ -45,11 +45,12 @@ class TickerController extends Controller
'erectDate' => '',
'nothing' => '',
'pjname' => $val->currency->pj_id
])->post('http://srh.bankofchina.com/search/whpj/search.jsp');
])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main'));
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
......@@ -57,6 +58,7 @@ class TickerController extends Controller
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
}
}
}
});
}
echo date('Y-m-d H:i:s') . '计价货币更新成功' . PHP_EOL;
......
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