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; }