public static function parseLhbHtml($html, $time) { $rows = $html->find('table#dt_1 tbody tr.all'); //echo $rows->plaintext; $ret = array(); $lcode = null; $lchage = null; foreach ($rows as $row) { $list = $row->find('td'); $res = array(); $res['time'] = $time; $code = null; if (sizeof($list) == 11) { //code $reu = trim($list[1]->plaintext); $code = CommonInfo::Num2Code($reu); //change $reu = trim($list[4]->plaintext); $res['change'] = $reu; $lcode = $code; $lchage = $res['change']; $i = 0; } else { if (sizeof($list) == 6) { $code = $lcode; $res['change'] = $lchage; $i = 5; } else { continue; } } if (!$code) { continue; } //buy_wan $reu = trim($list[6 - $i]->plaintext); $res['buy_wan'] = $reu; //buy_percent $reu = trim($list[7 - $i]->plaintext); $res['buy_percent'] = $reu; //sell_wan $reu = trim($list[8 - $i]->plaintext); $res['sell_wan'] = $reu; //sell_percent $reu = trim($list[9 - $i]->plaintext); $res['sell_percent'] = $reu; //reason $reu = trim($list[10 - $i]->plaintext); $res['reason'] = $reu; array_unshift($ret, array($code, $res)); } //var_dump($ret); return $ret; }
public static function Vague2List($importFile, $exportFile) { if ($content = BaseFile::getFileContent($importFile)) { $codeArr = array(); $r = "/[0-9.]{6}/"; preg_match_all($r, $content, $k); foreach ($k[0] as $t) { $tt = CommonInfo::Num2Code($t); if ($tt) { $codeArr[] = array('code' => $tt); } } } else { return false; } $codeNameArray = CommonInfo::CodeArray2CodeNameArray($codeArr); self::putList($exportFile, $codeNameArray); }
public static function parseRateHtml($html) { $rows = $html->find('div.table table tr'); //echo $rows->plaintext; $ret = array(); $pattern = "/[0-9]+/"; foreach ($rows as $row) { $list = $row->find('td'); if (sizeof($list) == 9) { //code $reu = $list[0]->find('a', 0)->href; //echo $reu; preg_match($pattern, $reu, $k); $code = CommonInfo::Num2Code($k[0]); $res = array(); //time $reu = trim($list[8]->plaintext); $res['time'] = $reu; //rate $reu = trim($list[5]->plaintext); $res['rate'] = $reu; //change $reu = trim($list[6]->plaintext); $res['change'] = $reu; //aim $reu = trim($list[7]->plaintext); $res['aim'] = $reu; //institute $reu = trim($list[3]->plaintext); $res['institute'] = $reu; //title $reu = trim($list[1]->plaintext); $res['title'] = $reu; //url $reu = $list[1]->find('a', 0)->href; $reu = 'http://yanbao.stock.hexun.com/' . $reu; $res['url'] = $reu; array_unshift($ret, array($code, $res)); } } //var_dump($ret); return $ret; }
public static function addInfo() { $importFile = self::$thisTaskDataPath . '20151200-21Good.List.txt'; $exportFile = self::$thisTaskDataPath . '20151200-21Good.Table.txt'; $stockList = parent::ReadList($importFile); $stockList = CommonInfo::CodeArray2ReferArray($stockList); $stockTable = array(); $pre = '2015-11-00'; $start = '2015-12-00'; $end = '2015-12-21'; foreach ($stockList as $stkL) { $stkT = array(); $stkT['name'] = '<a target="_blank" href="' . Url::getBasePhp('Stock') . '?code=' . $stkL['code'] . '">' . '<span class="fore-stock-name">' . $stkL['name'] . '</span>' . '<span class="fore-stock-spell displaynone">' . $stkL['spell'] . '</span></a>'; $stkT['code'] = '<span class="fore-stock-code">' . $stkL['code'] . '</span>'; //以上为标准的 索引 $tdd = new ThsDoctorData($stkL['code']); $t = $tdd->prepareData() ? $tdd->getDayPeriod($start, $end) : array(); //total_score $stkT['total_score_max'] = LogicOperation::highValue($t, 'total_score'); $stkT['total_score_min'] = LogicOperation::lowValue($t, 'total_score'); //message_score $stkT['message_score_max'] = LogicOperation::highValue($t, 'message_score'); $stkT['message_score_min'] = LogicOperation::lowValue($t, 'message_score'); //trade_score $stkT['trade_score_max'] = LogicOperation::highValue($t, 'trade_score'); $stkT['trade_score_min'] = LogicOperation::lowValue($t, 'trade_score'); //basic_score $stkT['basic_score_max'] = LogicOperation::highValue($t, 'basic_score'); $stkT['basic_score_min'] = LogicOperation::lowValue($t, 'basic_score'); //评级买入次数 $rd = new RateData($stkL['code']); $t = $rd->prepareData() ? $rd->getDayPeriod($pre, $end) : array(); $t = $rd->filterBuy($t); $stkT['rate_buy_num'] = $t ? sizeof($t) : 0; //龙虎榜次数 $ld = new LhbData($stkL['code']); $t = $ld->prepareData() ? $ld->getDayPeriod($start, $end) : array(); $stkT['lhb_num'] = $t ? sizeof($t) : 0; $stockTable[] = $stkT; } parent::putTable($exportFile, $stockTable); }
public static function testTmp() { $t = new Tmp(TMP_PATH); $p = CommonInfo::GetFileName(__FILE__); $t->addTmp($p, false); //$t->newTmpFile($p); $t->putTmpContent($p, "null", FILE_APPEND); echo $t->getTmpContent($p); }