Yacyunih.php 1.54 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
use App\Models\Searchengine;

7
class Yacyunih extends Searchengine
8
{
9
10
11
12
13
14
15
16
17
    public $results = [];

    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
    }

    public function loadResults($result)
    {
18
        $result = preg_replace("/\r\n/si", "", $result);
19
20
        try {
            $content = simplexml_load_string($result);
21
22
            if (!$content) {
                return;
23
24
            }

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
            $results = $content->xpath('//rss/channel/item');
            if (!$results) {
                return;
            }
            $count = 0;
            foreach ($results as $result) {
                if ($count > 10) {
                    break;
                }
                $title       = $result->{"title"}->__toString();
                $link        = $result->{"link"}->__toString();
                $anzeigeLink = $link;
                $descr       = strip_tags($result->{"description"}->__toString());
                $this->counter++;
                $this->results[] = new \App\Models\Result(
                    $this->engine,
                    $title,
                    $link,
                    $anzeigeLink,
                    $descr,
                    $this->gefVon,
                    $this->counter
                );
                $count++;
            }
        } catch (\Exception $e) {
            Log::error("A problem occurred parsing results from $this->name");
            return;
53
54
55
        }
    }
}