Minisucher.php 1.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace App\Models\parserSkripte;

use App\Models\Searchengine;

class Minisucher extends Searchengine
{

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

15
	public function loadResults ($content)
16
	{
17
18
19
20
21
		try {
			$content = simplexml_load_string($content);
		} catch (\Exception $e) {
			return;
		}
22
23
24
25
26
27
28
29
30
		if(!$content)
		{
			return;
		}
		$results = $content->xpath('//response/result/doc');

		$string = "";
		
		$counter = 0;
31
		$providerCounter = [];
32
33
		foreach($results as $result)
		{
34
35
36
			try{
				$counter++;
				$result = simplexml_load_string($result->saveXML());
37

38
39
40
41
42
43
44
45
46
47
48
				$title = $result->xpath('//doc/arr[@name="title"]/str')[0]->__toString();
				$link = $result->xpath('//doc/str[@name="url"]')[0]->__toString();
				$anzeigeLink = $link;
				$descr = "";
				$descriptions = $content->xpath("//response/lst[@name='highlighting']/lst[@name='$link']/arr[@name='content']/str");
				foreach($descriptions as $description)
				{
					$descr .= $description->__toString();
				}
				$descr = strip_tags($descr);
				$provider = $result->xpath('//doc/str[@name="subcollection"]')[0]->__toString();
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

				if( isset($providerCounter[$provider]) && $providerCounter[$provider] > 10 )
					continue;
				else
				{
					if( !isset($providerCounter[$provider]) )
						$providerCounter[$provider] = 0;
					$providerCounter[$provider] += 1;
				}

				if( isset($provider) )
				{
					$gefVon = "<a href=\"https://metager.de\" target=\"_blank\">Minisucher: $provider</a>";
				}else
				{
					$gefVon = $this->gefVon;
				}

67
68
69
70
71
72
				$this->results[] = new \App\Models\Result(
						$this->engine,
						$title,
						$link,
						$link,
						$descr,
73
						$gefVon,
74
75
76
						$counter
						);
			}catch(\ErrorException $e)
77
			{
78
				continue;
79
80
81
82
83
84
85
			}
		}
		
		
	}

}