Commit ec20589b authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Yacy repariert

parent 1d933473
...@@ -122,7 +122,11 @@ abstract class Searchengine ...@@ -122,7 +122,11 @@ abstract class Searchengine
}else{ }else{
$url = "http://"; $url = "http://";
} }
$url .= $this->host . $this->getString; $url .= $this->host;
if($this->port !== 80 && $this->port !== 443){
$url .= ":" . $this->port;
}
$url .= $this->getString;
$url = base64_encode($url); $url = base64_encode($url);
$mission = $this->resultHash . ";" . $url . ";" . $metager->getTime(); $mission = $this->resultHash . ";" . $url . ";" . $metager->getTime();
// Submit this mission to the corresponding Redis Queue // Submit this mission to the corresponding Redis Queue
......
...@@ -16,23 +16,18 @@ class Yacy extends Searchengine ...@@ -16,23 +16,18 @@ class Yacy extends Searchengine
public function loadResults($result) public function loadResults($result)
{ {
$result = preg_replace("/\r\n/si", "", $result);
try {
$content = simplexml_load_string($result);
if (!$content) {
return;
}
$results = $content->xpath("//rss/channel/item"); try {
if (!$results) { $content = json_decode($result, true);
return; $content = $content["channels"];
}
foreach($content as $channel){
foreach ($results as $res) { $items = $channel["items"];
$title = $res->{"title"}; foreach($items as $item){
$link = $res->{"link"}; $title = $item["title"];
$link = $item["link"];
$anzeigeLink = $link; $anzeigeLink = $link;
$descr = $res->{"description"}; $descr = $item["description"];
$this->counter++; $this->counter++;
$this->results[] = new \App\Models\Result( $this->results[] = new \App\Models\Result(
...@@ -45,6 +40,8 @@ class Yacy extends Searchengine ...@@ -45,6 +40,8 @@ class Yacy extends Searchengine
$this->counter $this->counter
); );
} }
}
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:"); Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage()); Log::error($e->getMessage());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment