LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

hidden_service.php (1468B)

      1 <?php
      2     require "engines/text/text.php";
      3 
      4     class TorSearch extends EngineRequest {
      5         public function get_request_url() {
      6             return "https://ahmia.fi/search/?q=" . urlencode($this->query);
      7         }
      8 
      9         public function parse_results($response) {
     10             $results = array();
     11             $xpath = get_xpath($response);
     12 
     13             if (!$xpath)
     14                 return $results;
     15 
     16             foreach($xpath->query("//ol[@class='searchResults']//li[@class='result']") as $result)
     17             {
     18                 $url = "http://" . $xpath->evaluate(".//cite", $result)[0]->textContent;
     19                 $title = remove_special($xpath->evaluate(".//h4", $result)[0]->textContent);
     20                 $description = $xpath->evaluate(".//p", $result)[0]->textContent;
     21 
     22                 array_push($results,
     23                     array (
     24                         "title" => $title ? htmlspecialchars($title) : TEXTS["result_no_description"],
     25                         "url" =>  htmlspecialchars($url),
     26                         // base_url is to be removed in the future, see #47
     27                         "base_url" => htmlspecialchars(get_base_url($url)),
     28                         "description" => htmlspecialchars($description)
     29                     )
     30                 );
     31             }
     32 
     33             return $results;
     34         }
     35 
     36         public static function print_results($results, $opts) {
     37             TextSearch::print_results($results, $opts);
     38         }
     39     }
     40 ?>