Yacy.php 1.34 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
use App\Models\Searchengine;

7
class Yacy extends Searchengine
8
9
10
{
    public $results = [];

11
    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
12
13
14
15
    {
        parent::__construct($engine, $metager);
    }

16
    public function loadResults($result)
17
    {
18
        $result = preg_replace("/\r\n/si", "", $result);
19
20
        try {
            $content = simplexml_load_string($result);
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
            if (!$content) {
                return;
            }

            $results = $content->xpath("//rss/channel/item");
            if (!$results) {
                return;
            }

            foreach ($results as $res) {
                $title       = $res->{"title"};
                $link        = $res->{"link"};
                $anzeigeLink = $link;
                $descr       = $res->{"description"};

                $this->counter++;
                $this->results[] = new \App\Models\Result(
                    $this->engine,
                    $title,
                    $link,
                    $anzeigeLink,
                    $descr,
                    $this->gefVon,
                    $this->counter
                );
            }
47
        } catch (\Exception $e) {
48
            Log::error("A problem occurred parsing results from $this->name");
49
            return;
50
        }
51
    }
52
}