Commit a7ae2d12 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '49-produktsuche-funktioniert-noch-nicht' into 'master'

Resolve "Produktsuche funktioniert noch nicht."

Closes #49 Closes #50 

See merge request !52
parents 820cc0ee f7a2bae1
......@@ -25,6 +25,8 @@ abstract class Searchengine
foreach($engine->attributes() as $key => $value){
$this->$key = $value->__toString();
}
if( !isset($this->homepage) )
$this->homepage = "https://metager.de";
$this->engine = $engine;
# Wir registrieren die Benutzung dieser Suchmaschine
......
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
class Ecoshopper extends Searchengine
{
public $results = [];
function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
}
public function loadResults ($result)
{
try {
$content = simplexml_load_string($result);
} catch (\Exception $e) {
abort(500, "$result is not a valid xml string");
}
if(!$content)
{
return;
}
$results = $content->xpath('//response/result[@name="response"]/doc');
foreach($results as $result)
{
$result = simplexml_load_string($result->saveXML());
$title = $result->xpath('//doc/str[@name="artikelName"]')[0]->__toString();
$link = $result->xpath('//doc/str[@name="artikelDeeplink"]')[0]->__toString();
$anzeigeLink = parse_url($link);
if( isset($anzeigeLink['query']) )
{
parse_str($anzeigeLink['query'], $query);
if( isset($query['diurl']) )
$anzeigeLink = $query['diurl'];
else
$anzeigeLink = $link;
}else
{
$anzeigeLink = $link;
}
$descr = $result->xpath('//doc/str[@name="artikelBeschreibung"]')[0]->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
}
}
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
class Fairmondo extends Searchengine
{
public $results = [];
function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
}
public function loadResults ($result)
{
$results = json_decode($result, true);
$results = $results["articles"];
foreach($results as $result)
{
$title = $result["title"];
$link = $result["html_url"];
$anzeigeLink = $link;
$descr = $result["slug"];
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
}
}
\ No newline at end of file
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
class Mg_produkt2 extends Searchengine
{
public $results = [];
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);
} catch (\Exception $e) {
abort(500, "$result is not a valid xml string");
}
if(!$content)
{
return;
}
$results = $content->xpath('//response/result[@name="response"]/doc');
foreach($results as $result)
{
$result = simplexml_load_string($result->saveXML());
$title = $result->xpath('/doc/arr[@name="artikelName"]')[0]->{"str"}->__toString();
$link = $result->xpath('/doc/arr[@name="artikelDeeplink"]')[0]->{"str"}->__toString();
$anzeigeLink = parse_url($link);
parse_str($anzeigeLink['query'], $query);
$anzeigeLink = $query['diurl'];
$descr = $result->xpath('/doc/arr[@name="artikelBeschreibung"]')[0]->{"str"}->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
);
}
}
}
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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