Commit b04f6e80 authored by Dominik Hebeler's avatar Dominik Hebeler

Query Filter are working switched to sumas.json

parent fe962cd0
......@@ -161,6 +161,7 @@ class Searcher implements ShouldQueue
// Set this URL to the Curl handle
curl_setopt($this->ch, CURLOPT_URL, $url);
$result = curl_exec($this->ch);
$this->connectionInfo = curl_getinfo($this->ch);
return $result;
}
......@@ -203,10 +204,13 @@ class Searcher implements ShouldQueue
}
if ($this->headers !== null) {
$headers = [];
foreach ($this->headers as $key => $value) {
$headers[] = $key . ":" . $value;
}
# Headers are in the Form:
# <key>:<value>;<key>:<value>
$headerArray = explode(";", $this->headers);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
return $ch;
......
This diff is collapsed.
......@@ -31,7 +31,6 @@ class Result
# Erstellt ein neues Ergebnis
public function __construct($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $gefVonLink, $sourceRank, $additionalInformation = [])
{
$provider = simplexml_load_string($provider);
$this->titel = strip_tags(trim($titel));
$this->link = trim($link);
$this->anzeigeLink = trim($anzeigeLink);
......@@ -52,8 +51,8 @@ class Result
$this->sourceRank = 20;
}
$this->sourceRank = 20 - $this->sourceRank;
if (isset($provider["engineBoost"])) {
$this->engineBoost = floatval($provider["engineBoost"]->__toString());
if (isset($provider->{"engine-boost"})) {
$this->engineBoost = floatval($provider->{"engine-boost"});
} else {
$this->engineBoost = 1;
}
......@@ -275,22 +274,6 @@ class Result
}
}
*/
/* Der Host-Filter der sicherstellt,
* dass von jedem Host maximal 3 Links angezeigt werden.
* Diese Überprüfung führen wir unter bestimmten Bedingungen nicht durch.
*/
if (($metager->getSite() === "" || $metager->getSite() === null) &&
strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false &&
strpos($this->strippedHost, "twitter.com") === false &&
strpos($this->strippedHost, "www.ladenpreis.net") === false &&
strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false &&
strpos($this->strippedHost, "www.onenewspage.com") === false &&
$this->gefVon !== "Shopzilla") {
$count = $metager->getHostCount($this->strippedHost);
if ($count >= 3) {
return false;
}
}
/* Der Dublettenfilter, der sicher stellt,
* dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben.
......
This diff is collapsed.
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Symfony\Component\DomCrawler\Crawler;
use Log;
class Bing extends Searchengine
{
public $results = [];
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
}
public function loadResults($result)
{
try {
$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->displayName,$this->homepage,
$this->counter
);
});
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
}
......@@ -9,9 +9,9 @@ class BingBilder extends Searchengine
{
public $results = [];
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
public function __construct($name, \stdClass $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
parent::__construct($name, $engine, $metager);
}
public function loadResults($result)
......@@ -33,7 +33,7 @@ class BingBilder extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->displayName, $this->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['image' => $image]
);
......@@ -59,12 +59,9 @@ class BingBilder extends Searchengine
return;
}
$next = new BingBilder(simplexml_load_string($this->engine), $metager);
if (\str_contains($next->getString, "&offset=")) {
$next->getString = preg_replace("/&offset=.*/si", "", $next->getString);
}
$next->getString .= "&offset=" . $nextOffset;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$newEngine = unserialize(serialize($this->engine));
$newEngine->{"get-parameter"}->offset = $nextOffset;
$next = new BingBilder($this->name, $newEngine, $metager);
$this->next = $next;
} catch (\Exception $e) {
......
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Symfony\Component\DomCrawler\Crawler;
class Bing_bilder extends Searchengine
{
public $results = [];
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
}
public function loadResults($result)
{
$crawler = new Crawler($result);
$crawler->filter('div#b_content div.item')->each(function (Crawler $node, $i) {
$title = $node->filter('div.meta > a.tit')->text();
$link = $node->filter('div.meta > a.tit')->attr("href");
$anzeigeLink = $link;
$descr = $node->filter('div.meta > div.des')->text();
$image = $node->filter('a.thumb img')->attr("src");
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->displayName,$this->homepage,
$this->counter,
['image' => $image]
);
});
}
}
......@@ -9,9 +9,12 @@ class Overture extends Searchengine
{
public $results = [];
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
public function __construct($name, \stdClass $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
parent::__construct($name, $engine, $metager);
# We need some Affil-Data for the advertisements
$this->getString .= $this->getOvertureAffilData($metager->getUrl());
$this->hash = md5($this->engine->host . $this->getString . $this->engine->port . $this->name);
}
public function loadResults($result)
......@@ -36,8 +39,8 @@ class Overture extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->displayName,
$this->homepage,
$this->engine->{"display-name"},
$this->engine->homepage,
$this->counter
);
}
......@@ -56,7 +59,7 @@ class Overture extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->displayName, $this->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter
);
}
......@@ -112,9 +115,21 @@ class Overture extends Searchengine
}
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$next = new Overture(simplexml_load_string($this->engine), $metager);
$next = new Overture($this->name, $this->engine, $metager);
$next->getString = preg_replace("/&Keywords=.*?&/si", "&", $next->getString) . "&" . $nextArgs;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$next->hash = md5($next->engine->host . $next->getString . $next->engine->port . $next->name);
$this->next = $next;
}
# Liefert Sonderdaten für Yahoo
private function getOvertureAffilData($url)
{
$affil_data = 'ip=' . $this->ip;
$affil_data .= '&ua=' . $this->useragent;
$affilDataValue = $this->urlEncode($affil_data);
# Wir benötigen die ServeUrl:
$serveUrl = $this->urlEncode($url);
return "&affilData=" . $affilDataValue . "&serveUrl=" . $serveUrl;
}
}
......@@ -9,9 +9,9 @@ class Scopia extends Searchengine
{
public $results = [];
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
public function __construct($name, \stdClass $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
parent::__construct($name, $engine, $metager);
}
public function loadResults($result)
......@@ -30,6 +30,7 @@ class Scopia extends Searchengine
$results = $content->xpath('//results/result');
foreach ($results as $result) {
$title = $result->title->__toString();
$link = $result->url->__toString();
$anzeigeLink = $link;
......@@ -41,8 +42,8 @@ class Scopia extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->displayName,
$this->homepage,
$this->engine->{"display-name"},
$this->engine->homepage,
$this->counter
);
}
......@@ -76,9 +77,9 @@ class Scopia extends Searchengine
$results = $content->xpath('//results/result');
$number = $results[sizeof($results) - 1]->number->__toString();
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$next = new Scopia(simplexml_load_string($this->engine), $metager);
$next->getString = preg_replace("/\\?s=.*?&/si", "?s=" . $number, $next->getString);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$newEngine = unserialize(serialize($this->engine));
$newEngine->{"get-parameter"}->s = $number;
$next = new Scopia($this->name, $newEngine, $metager);
$this->next = $next;
}
......
......@@ -7,6 +7,7 @@ return [
'settings.noneSelected' => 'Achtung: Sie haben in ihren Einstellungen keine Suchmaschine ausgewählt.',
'engines.noParser' => 'Beim Abfragen von :engine ist ein Fehler aufgetreten. Bitte benachrichtigen Sie uns unter: office@suma-ev.de',
'engines.noSpecialSearch' => 'Für eine Ihrer Filteroptionen gab es keine Suchmaschine im aktuellen Fokus (:fokus), welche diese unterstützen würde. Sie haben folgende(n) Filter aktiv: ":filter".',
'formdata.cantLoad' => 'Suma-File konnte nicht gefunden werden',
'formdata.noSearch' => 'Achtung: Sie haben keinen Suchbegriff eingegeben. Sie können ihre Suchbegriffe oben eingeben und es erneut versuchen.',
......@@ -20,4 +21,5 @@ return [
'sitesearch.failed' => 'Sie wollten eine Sitesearch auf :site durchführen. Leider unterstützen die eingestellten Suchmaschinen diese nicht. Sie können die Sitesearch im Web-Fokus durchführen. Es werden ihnen Ergebnisse ohne Sitesearch angezeigt.',
'sitesearch.success' => 'Sie führen eine Sitesearch durch. Es werden nur Ergebnisse von der Seite: ":site" angezeigt.',
'feedback' => 'Nichts Passendes dabei? Geben Sie uns Feedback: ',
'filter.sitesearch' => 'Sitesearch',
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment