OvertureAds.php 1.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
<?php

namespace App\Models\parserSkripte;

use App\Models\Searchengine;

class OvertureAds extends Searchengine
{

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

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

            $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing');
            foreach ($ads as $ad) {
                $title       = $ad["title"];
                $link        = $ad->{"ClickUrl"}->__toString();
                $anzeigeLink = $ad["siteHost"];
                $descr       = $ad["description"];
                $this->counter++;
                $this->ads[] = new \App\Models\Result(
                    $this->engine,
                    $title,
                    $link,
                    $anzeigeLink,
                    $descr,
                    $this->gefVon,
                    $this->counter
                );
            }
41
        } catch (\Exception $e) {
42
            Log::error("A problem occurred parsing results from $this->name");
43
44
45
46
47
            return;
        }
    }

}