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,17 +61,19 @@ 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){
$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');
break;
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');
break;
}
}
}
}
......
......@@ -45,16 +45,18 @@ 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'));
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
$currency = rtrim(sprintf('%.6f', 1 / ($e->innertext / 100)), '0');
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
$currency = rtrim(sprintf('%.6f', 1 / ($e->innertext / 100)), '0');
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
}
}
}
});
......
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