예제 #1
0
파일: Message.php 프로젝트: sasezaki/spizer
 public function getBody()
 {
     $data = Zend_Json::decode($this->_data['body']);
     $request = new Kumo_Request($data['uri'], $data['method']);
     $request->setAllHeaders(isset($data['headers']) ? $data['headers'] : null);
     $request->setBody(isset($data['body']) ? $data['body'] : null);
     $request->setReferrer(isset($data['referrer']) ? $data['referrer'] : null);
     return $request;
 }
예제 #2
0
 public function handle(Spizer_Document $doc)
 {
     //$this->debug('********START****');
     if (!$doc instanceof Spizer_Document_Html) {
         return;
     }
     $headers = $doc->getAllHeaders();
     //response is already decoded.
     unset($headers['transfer-encoding']);
     unset($headers['content-encoding']);
     $results = $this->scraper->scrape(new Zend_Http_Response($doc->getStatus(), $headers, $doc->getBody()), $doc->getUrl());
     //$this->debug($results);
     $targets = $this->filter(array_unique($results['kumo']));
     foreach ($targets as $src) {
         //$request = new Spizer_Request($src);
         $request = new Kumo_Request($src);
         $request->setReferrer($doc->getUrl());
         //if ($this->_config['referer'] === true) {
         $request->setHeader('Referer', $this->toRefererUrl($doc->getUrl()));
         //}
         $this->send($request);
     }
 }