hidden_service.php 1.4 KB

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