cnz.php<?php/*******************************************************************************Version: 1.11 ($Rev: 175 $)Website: http://www.115.coAutho......
$check = $this->match($exp, $val, $k); if ($check) break; } } if (!$check) $pass = false; } if ($pass) $ret[$i] = 1; unset($node); } }
protected function match($exp, $pattern, $value) { switch ($exp) { case '=': return ($value===$pattern); case '!=': return ($value!==$pattern); case '^=': return preg_match("/^".preg_quote($pattern,'/')."/", $value); case '$=': return preg_match("/".preg_quote($pattern,'/')."$/", $value); case '*=': if ($pattern[0]=='/') return preg_match($pattern, $value); return preg_match("/".$pattern."/i", $value); } return false; }
protected function parse_selector($selector_string) { // pattern of CSS selectors, modified from mootools $pattern = "/([\w-:\*]*)(?:\#([\w-] )|\.([\w-] ))?(?:\[@?(!?[\w-] )(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ] )/is"; preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); $selectors = array(); $result = array(); //print_r($matches);
foreach ($matches as $m) { $m[0] = trim($m[0]); if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; // for borwser grnreated xpath if ($m[1]==='tbody') continue;
list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); if(!empty($m[2])) {$key='id'; $val=$m[2];} if(!empty($m[3])) {$key='class'; $val=$m[3];} if(!empty($m[4])) {$key=$m[4];} if(!empty($m[5])) {$exp=$m[5];} if(!empty($m[6])) {$val=$m[6];}
// convert to lowercase if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} //elements that do NOT have the specified attribute if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
$result[] = array($tag, $key, $val, $exp, $no_key); if (trim($m[7])===',') { $selectors[] = $result; $result = array();
6/18 首页 上一页 4 5 6 7 8 9 下一页 尾页 |