Commit eec7c85e authored by Dominik Hebeler's avatar Dominik Hebeler

Shopzilla hinzugefügt

parent 8776ab51
Pipeline #2262 passed with stage
in 58 seconds
......@@ -422,7 +422,7 @@ class MetaGer
$hash = $el[1];
foreach ($results as $result) {
if ($hoster === $result->tld) {
if ($hoster === $result->tld && !$result->partnershop) {
# Hier ist ein Advertiser:
# Das Logo hinzufügen:
if ($result->image !== "") {
......
......@@ -270,7 +270,8 @@ class Result
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) {
strpos($this->strippedHost, "www.onenewspage.com") === false &&
$this->gefVon !== "Shopzilla" ){
$count = $metager->getHostCount($this->strippedHost);
if ($count >= 3) {
return false;
......
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Log;
class Shopzilla extends Searchengine
{
public $results = [];
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);
if (!$content) {
return;
}
$results = $content->{"Products"};
$count = 0;
foreach ($results->{"Offer"} as $result) {
$title = $result->{"title"}->__toString();
$link = $result->{"url"}->__toString();
$anzeigeLink = $result->{"rawUrl"}->__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->displayName,$this->homepage,
$this->counter,
['partnershop' => true,
'price' => $price,
'image' => $image]
);
$count++;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
public function getNext(\App\MetaGer $metager, $result)
{
$result = preg_replace("/\r\n/si", "", $result);
try {
$content = simplexml_load_string($result);
if (!$content) {
return;
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
// Get total Result Count
$totalResults = intval($content->{"Products"}["totalResults"]->__toString());
// 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){
$tmp = substr($tmp, 0, strpos($tmp, "&"));
}
$current = intval($tmp);
}
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->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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