Bing.php 1.17 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
7
use App\Models\Searchengine;
use Symfony\Component\DomCrawler\Crawler;

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

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

    public function loadResults($result)
    {
19
        try {
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
            $crawler = new Crawler($result);
            $crawler->filter('ol#b_results > li.b_algo')->each(function (Crawler $node, $i) {
                $title       = $node->filter('li h2 > a')->text();
                $link        = $node->filter('li h2 > a')->attr('href');
                $anzeigeLink = $link;
                $descr       = $node->filter('li div > p')->text();

                $this->counter++;
                $this->results[] = new \App\Models\Result(
                    $this->engine,
                    $title,
                    $link,
                    $anzeigeLink,
                    $descr,
                    $this->gefVon,
                    $this->counter
                );
            });
        } catch (\ErrorException $e) {
            return;
        }

    }
}