Fastbot.php 1.46 KB
Newer Older
1
2
<?php

3
namespace app\Models\parserSkripte;
4

5
use App\Models\Searchengine;
6

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

    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
        if (strpos($this->urlEncode($metager->getEingabe()), "%") !== false) {
            $this->enabled = false;
            return null;
        }
    }
19

20
21
22
23
24
25
26
27
28
29
30
31
32
    public function loadResults($result)
    {
        $result  = utf8_encode($result);
        $counter = 0;
        foreach (explode("\n", $result) as $line) {
            $line = trim($line);
            if (strlen($line) > 0) {
                # Hier bekommen wir jedes einzelne Ergebnis
                $result = explode("|:|", $line);
                $link   = $result[1];
                $link   = substr($link, strpos($link, "href=\"") + 6);
                $link   = substr($link, 0, strpos($link, "\""));
                $counter++;
33
                $this->gefVon    = "<a href=\"" . $this->homepage . "\" target=\"_blank\" rel=\"noopener\">" . $this->displayName . " " . trans('results.redirect') . "</a>";
34
35
36
37
38
39
40
41
42
43
                $this->results[] = new \App\Models\Result(
                    $this->engine,
                    trim(strip_tags($result[1])),
                    $link,
                    $result[3],
                    $result[2],
                    $this->gefVon,
                    $counter
                );
            }
44

45
        }
46

47
48
    }
}