Commit 087c4fe4 authored by Dominik Hebeler's avatar Dominik Hebeler

Fixed a bug in parser scripts

parent 4001e042
......@@ -33,8 +33,8 @@ class Europeana extends Searchengine
$link = "";
}
$anzeigeLink = $link;
$descr = "";
$image = urldecode($result->edmPreview[0]);
$descr = "";
$image = urldecode($result->edmPreview[0]);
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -42,7 +42,7 @@ class Europeana extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['image' => $image]
);
......@@ -67,7 +67,7 @@ class Europeana extends Searchengine
if ($start > $content->totalResults) {
return;
}
$next = new Europeana(simplexml_load_string($this->engine), $metager);
$next = new Europeana($this->engine, $metager);
$next->getString .= "&start=" . $start;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -25,11 +25,11 @@ class Flickr extends Searchengine
$results = $content->xpath('//photos/photo');
foreach ($results as $result) {
$title = $result["title"]->__toString();
$link = "https://www.flickr.com/photos/" . $result["owner"]->__toString() . "/" . $result["id"]->__toString();
$title = $result["title"]->__toString();
$link = "https://www.flickr.com/photos/" . $result["owner"]->__toString() . "/" . $result["id"]->__toString();
$anzeigeLink = $link;
$descr = "";
$image = "http://farm" . $result["farm"]->__toString() . ".staticflickr.com/" . $result["server"]->__toString() . "/" . $result["id"]->__toString() . "_" . $result["secret"]->__toString() . "_t.jpg";
$descr = "";
$image = "http://farm" . $result["farm"]->__toString() . ".staticflickr.com/" . $result["server"]->__toString() . "/" . $result["id"]->__toString() . "_" . $result["secret"]->__toString() . "_t.jpg";
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -37,7 +37,7 @@ class Flickr extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['image' => $image]
);
......@@ -58,12 +58,12 @@ class Flickr extends Searchengine
return;
}
$page = $metager->getPage() + 1;
$page = $metager->getPage() + 1;
$results = $content->xpath('//photos')[0];
if ($page >= intval($results["pages"]->__toString())) {
return;
}
$next = new Flickr(simplexml_load_string($this->engine), $metager);
$next = new Flickr($this->name, $this->engine, $metager);
$next->getString .= "&page=" . $page;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -6,7 +6,7 @@ use App\Models\Searchengine;
class Onenewspage extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
......@@ -24,10 +24,10 @@ class Onenewspage extends Searchengine
if (sizeof($res) < 3) {
continue;
}
$title = $res[0];
$link = $res[2];
$anzeigeLink = $link;
$descr = $res[1];
$title = $res[0];
$link = $res[2];
$anzeigeLink = $link;
$descr = $res[1];
$additionalInformation = sizeof($res) > 3 ? ['date' => intval($res[3])] : [];
$this->counter++;
......@@ -37,7 +37,7 @@ class Onenewspage extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
$additionalInformation
);
......@@ -54,9 +54,9 @@ class Onenewspage extends Searchengine
return;
}
$next = new Onenewspage(simplexml_load_string($this->engine), $metager);
$next = new Onenewspage($this->name, $this->engine, $metager);
$next->resultCount = $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->getString .= "&o=" . $next->offset;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -7,7 +7,7 @@ use App\Models\Searchengine;
class Onenewspagegermany extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
......@@ -27,10 +27,10 @@ class Onenewspagegermany extends Searchengine
if (sizeof($result) < 3) {
continue;
}
$title = $result[0];
$link = $result[2];
$anzeigeLink = $link;
$descr = $result[1];
$title = $result[0];
$link = $result[2];
$anzeigeLink = $link;
$descr = $result[1];
$additionalInformation = sizeof($result) > 3 ? ['date' => intval($result[3])] : [];
$counter++;
......@@ -40,7 +40,7 @@ class Onenewspagegermany extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
$additionalInformation
);
......@@ -59,9 +59,9 @@ class Onenewspagegermany extends Searchengine
return;
}
$next = new Onenewspagegermany(simplexml_load_string($this->engine), $metager);
$next = new Onenewspagegermany($this->name, $this->engine, $metager);
$next->resultCount = $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->getString .= "&o=" . $next->offset;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -6,7 +6,7 @@ use App\Models\Searchengine;
class Onenewspagevideo extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
......@@ -23,10 +23,10 @@ class Onenewspagevideo extends Searchengine
if (sizeof($res) < 3) {
continue;
}
$title = $res[0];
$link = $res[2];
$anzeigeLink = $link;
$descr = $res[1];
$title = $res[0];
$link = $res[2];
$anzeigeLink = $link;
$descr = $res[1];
$additionalInformation = sizeof($res) > 3 ? ['date' => intval($res[3])] : [];
$this->counter++;
......@@ -36,7 +36,7 @@ class Onenewspagevideo extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
$additionalInformation
);
......@@ -52,9 +52,9 @@ class Onenewspagevideo extends Searchengine
return;
}
$next = new Onenewspagevideo(simplexml_load_string($this->engine), $metager);
$next = new Onenewspagevideo($this->name, $this->engine, $metager);
$next->resultCount = $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->offset = $this->offset + $this->resultCount;
$next->getString .= "&o=" . $next->offset;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -25,11 +25,11 @@ class Openclipart extends Searchengine
$results = $content->payload;
foreach ($results as $result) {
$title = $result->title;
$link = $result->detail_link;
$title = $result->title;
$link = $result->detail_link;
$anzeigeLink = $link;
$descr = $result->description;
$image = $result->svg->png_thumb;
$descr = $result->description;
$image = $result->svg->png_thumb;
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -37,7 +37,7 @@ class Openclipart extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['image' => $image]
);
......@@ -60,7 +60,7 @@ class Openclipart extends Searchengine
if ($content->info->current_page > $content->info->pages) {
return;
}
$next = new Openclipart(simplexml_load_string($this->engine), $metager);
$next = new Openclipart($this->name, $this->engine, $metager);
$next->getString .= "&page=" . ($metager->getPage() + 1);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -25,11 +25,11 @@ class Pixabay extends Searchengine
$results = $content->hits;
foreach ($results as $result) {
$title = $result->tags;
$link = $result->pageURL;
$title = $result->tags;
$link = $result->pageURL;
$anzeigeLink = $link;
$descr = "";
$image = $result->previewURL;
$descr = "";
$image = $result->previewURL;
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -37,7 +37,7 @@ class Pixabay extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['image' => $image]
);
......@@ -70,7 +70,7 @@ class Pixabay extends Searchengine
if ($page * 20 > $content->total) {
return;
}
$next = new Pixabay(simplexml_load_string($this->engine), $metager);
$next = new Pixabay($this->name, $this->engine, $metager);
$next->getString .= "&page=" . $page;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
......
......@@ -24,34 +24,34 @@ class Shopzilla extends Searchengine
}
$results = $content->{"Products"};
$count = 0;
$count = 0;
foreach ($results->{"Offer"} as $result) {
$title = $result->{"title"}->__toString();
$link = $result->{"url"}->__toString();
$title = $result->{"title"}->__toString();
$link = $result->{"url"}->__toString();
$anzeigeLink = $result->{"rawUrl"}->__toString();
// Try to extract the display Urls:
if(preg_match("/^http[s]{0,1}:\/\/ad.eanalyzer.de/", $anzeigeLink)){
if (preg_match("/^http[s]{0,1}:\/\/ad.eanalyzer.de/", $anzeigeLink)) {
$parts = parse_url($anzeigeLink);
parse_str($parts['query'], $query);
$anzeigeLink = $query["url"];
}
$descr = $result->{"description"}->__toString();
$image = $result->{"Images"}->{"Image"}[1]->__toString();
$price = $result->{"price"}->__toString();
$descr = $result->{"description"}->__toString();
$image = $result->{"Images"}->{"Image"}[1]->__toString();
$price = $result->{"price"}->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter,
['partnershop' => true,
'price' => $price,
'image' => $image]
'price' => $price,
'image' => $image]
);
$count++;
}
......@@ -81,27 +81,27 @@ class Shopzilla extends Searchengine
// Get the current Result Position
$current = 0;
if(strpos($this->getString, "&start=") !== FALSE){
$tmp = substr($this->getString, strpos($this->getString, "&start=")+7);
if(strpos($tmp, "&") !== FALSE){
if (strpos($this->getString, "&start=") !== false) {
$tmp = substr($this->getString, strpos($this->getString, "&start=") + 7);
if (strpos($tmp, "&") !== false) {
$tmp = substr($tmp, 0, strpos($tmp, "&"));
}
$current = intval($tmp);
}
if($current >= ($totalResults - 10)){
if ($current >= ($totalResults - 10)) {
return;
}
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$next = new Shopzilla(simplexml_load_string($this->engine), $metager);
if(strpos($next->getString, "&start=") !== FALSE){
$next->getString = preg_replace("/&start=\d+/si", "&start=" . ($current+10), $next->getString);
}else{
$next->getString .= "&start=" . ($current+10);
$next = new Shopzilla($this->name, $this->engine, $metager);
if (strpos($next->getString, "&start=") !== false) {
$next->getString = preg_replace("/&start=\d+/si", "&start=" . ($current + 10), $next->getString);
} else {
$next->getString .= "&start=" . ($current + 10);
}
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
......@@ -27,17 +27,16 @@ class Yandex extends Searchengine
# in that case we will ignore all results because that would mean
# a string search (query between "") was wished and no results for that foudn
$reask = $content->xpath("//yandexsearch/response/reask");
if(sizeof($reask) !== 0 && $reask[0]->{"rule"}->__toString()){
if (sizeof($reask) !== 0 && $reask[0]->{"rule"}->__toString()) {
return;
}
$results = $content->xpath("//yandexsearch/response/results/grouping/group");
foreach ($results as $result) {
$title = strip_tags($result->{"doc"}->{"title"}->asXML());
$link = $result->{"doc"}->{"url"}->__toString();
$title = strip_tags($result->{"doc"}->{"title"}->asXML());
$link = $result->{"doc"}->{"url"}->__toString();
$anzeigeLink = $link;
$descr = strip_tags($result->{"doc"}->{"headline"}->asXML());
$descr = strip_tags($result->{"doc"}->{"headline"}->asXML());
if (!$descr) {
$descr = strip_tags($result->{"doc"}->{"passages"}->asXML());
}
......@@ -48,7 +47,7 @@ class Yandex extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"}, $this->engine->homepage,
$this->counter
);
}
......@@ -67,16 +66,16 @@ class Yandex extends Searchengine
return;
}
$resultCount = $content->xpath('//yandexsearch/response/results/grouping/found[@priority="all"]');
if(!$resultCount || sizeof($resultCount) <= 0){
if (!$resultCount || sizeof($resultCount) <= 0) {
return;
}
$resultCount = intval($resultCount[0]->__toString());
$pageLast = $content->xpath('//yandexsearch/response/results/grouping/page')[0];
$pageLast = intval($pageLast["last"]->__toString());
$pageLast = $content->xpath('//yandexsearch/response/results/grouping/page')[0];
$pageLast = intval($pageLast["last"]->__toString());
if (count($this->results) <= 0 || $pageLast >= $resultCount) {
return;
}
$next = new Yandex(simplexml_load_string($this->engine), $metager);
$next = new Yandex($this->name, $this->engine, $metager);
$next->getString .= "&page=" . ($metager->getPage() + 1);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
} catch (\Exception $e) {
......
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