Changeset 16914
- Timestamp:
- 07/31/08 20:29:04 (5 years ago)
- Location:
- lang/php/Scraper/library/Diggin/Scraper
- Files:
-
- 3 modified
-
Process.php (modified) (1 diff)
-
Strategy/Abstract.php (modified) (3 diffs)
-
Strategy/Xpath.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/php/Scraper/library/Diggin/Scraper/Process.php
r16891 r16914 24 24 public function __toString() 25 25 { 26 return "\"".$this->expression.' , '.$this->name.' => '.$this->type."\""; 26 return '\''.$this->expression.'\' , '. 27 $this->name.' => '. 28 // if(!($this->type instanceof scraper)) {$this->type} else "" 29 '"'; 27 30 } 28 31 -
lang/php/Scraper/library/Diggin/Scraper/Strategy/Abstract.php
r16891 r16914 53 53 protected abstract function getValue($values, $process); 54 54 55 protected abstract staticfunction extract($values, $process);55 protected abstract function extract($values, $process); 56 56 57 57 public function getValues($context, $process) … … 64 64 $values = $context->scrape($process); 65 65 } else { 66 $values = null; 67 $values = $this->extract($context, $process); 66 try { 67 $values = $this->extract($context, $process); 68 } catch (Diggin_Scraper_Strategy_Exception $e) { 69 echo "error";echo PHP_EOL; return false; 70 } 68 71 } 69 72 … … 71 74 foreach ($values as $count => $val) { 72 75 foreach ($process->type->processes as $proc) { 73 $returns[$count][$proc->name] = $this->getValues($val, $proc); 76 //@todo 値がとれなかったとき、格納しないか空かどうかはconfigでやるべきかな 77 if (false !== $getval =$this->getValues($val, $proc)) { 78 $returns[$count][$proc->name] = $getval; 79 } 74 80 } 75 81 -
lang/php/Scraper/library/Diggin/Scraper/Strategy/Xpath.php
r16913 r16914 76 76 } 77 77 78 public staticfunction extract($values, $process)78 public function extract($values, $process) 79 79 { 80 80 //↓このハンドリングはxpathの記述自体が間違ってたとき(いらないかな?) 81 81 set_error_handler( 82 82 create_function('$errno, $errstr', 83 'if($errno) require_once "Diggin/Scraper/Strategy/ Xpath/Exception.php";84 throw new Diggin_Scraper_Strategy_ Xpath_Exception($errstr, $errno);'83 'if($errno) require_once "Diggin/Scraper/Strategy/Exception.php"; 84 throw new Diggin_Scraper_Strategy_Exception($errstr, $errno);' 85 85 ) 86 86 ); … … 88 88 restore_error_handler(); 89 89 90 // if (count($results) === 0) { 91 // //@todo notice error 92 // require_once 'Diggin/Scraper/Strategy/Exception.php'; 93 // throw new Diggin_Scraper_Strategy_Exception("couldn't find By Xpath, Process : $process"); 94 // } 95 // if ((isset($results[0])) && ($results[0] === false)) {//これはxpath記述自体が間違ってたとき 96 // require_once 'Diggin/Scraper/Strategy/Exception.php'; 97 // throw new Diggin_Scraper_Strategy_Exception("Couldn't find By Xpath, Process : $process"); 98 // } 90 if (count($results) === 0) { 91 require_once 'Diggin/Scraper/Strategy/Exception.php'; 92 throw new Diggin_Scraper_Strategy_Exception("couldn't find By Xpath, Process : $process"); 93 } 99 94 100 95 return $results;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)