Yacy.php 1.16 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

namespace app\Models\parserSkripte;
use App\Models\Searchengine;

class Yacy extends Searchengine 
{
    public $results = [];

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

    public function loadResults (String $result)
    {
        
       # die($result);
        try {
            $content = simplexml_load_string($result);
        } catch (\Exception $e) {
            abort(500, "$result is not a valid xml string");
        }

25
26
        if(!$content)
            return;
27
        $results = $content->xpath("//rss/channel/item");
28
29
        if(!$results)
            return;
30
31
32
33
34
35
36
37
38
        foreach($results as $res)
        {
            $title = $res->{"title"};
            $link = $res->{"link"};
            $anzeigeLink = $link;
            $descr = $res->{"description"};

            $this->counter++;
            $this->results[] = new \App\Models\Result(
39
                $this->engine,
40
41
42
43
44
45
46
47
48
49
                $title,
                $link,
                $anzeigeLink,
                $descr,
                $this->gefVon,
                $this->counter
            );
        }       
    }
}