Commit ad1f8008 authored by karl's avatar karl
Browse files

Die Europeana Bildersuche ist jetzt eingebaut. Leider liefert sie meist nur...

Die Europeana Bildersuche ist jetzt eingebaut. Leider liefert sie meist nur Bilder von Antiquitäten und Kunst, sowie ab und zu kein Vorschaubild, die Links funktionieren dann aber immernoch und zeigen auch ein Bild an.
parent 31b8d04c
......@@ -83,7 +83,7 @@ class Search extends Job implements ShouldQueue
break;
}
if( sizeof(($tmp = explode(": ", $data))) === 2 )
$headers[trim($tmp[0])] = trim($tmp[1]);
$headers[strtolower(trim($tmp[0]))] = trim($tmp[1]);
$c++;
}
while (true);
......@@ -91,13 +91,13 @@ class Search extends Job implements ShouldQueue
// end of headers
if(sizeof($headers) > 1){
$bodySize = 0;
if( isset($headers["Transfer-Encoding"]) && $headers["Transfer-Encoding"] === "chunked" )
if( isset($headers["transfer-encoding"]) && $headers["transfer-encoding"] === "chunked" )
{
$body = $this->readChunked();
}elseif( isset($headers['Content-Length']) )
}elseif( isset($headers['content-length']) )
{
$length = trim($headers['Content-Length']);
$length = trim($headers['content-length']);
if(is_numeric($length) && $length >= 1)
$body = $this->readBody($length);
$bodySize = strlen($body);
......@@ -111,7 +111,7 @@ class Search extends Job implements ShouldQueue
}
Redis::del($this->host . "." . $this->socketNumber);
if( isset($headers["Content-Encoding"]) && $headers['Content-Encoding'] === "gzip")
if( isset($headers["content-encoding"]) && $headers['content-encoding'] === "gzip")
{
$body = $this->gunzip($body);
}
......
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Symfony\Component\DomCrawler\Crawler;
class Europeana 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 = json_decode($result);
} catch (\Exception $e) {
abort(500, "$result is not a valid json string");
}
if(!$content)
{
return;
}
$results = $content->items;
foreach($results as $result)
{
if(isset($result->edmPreview)) {
$title = $result->title[0];
if (preg_match("/(.+)\?.*/si", $result->guid, $match)){
$link = $match[1];
} else {
$link = "";
}
$anzeigeLink = $link;
$descr = "";
/*if (preg_match("/(?:uri=)(.+)/si", urldecode($result->edmPreview[0]), $match)){
$image = $match[1];
} else {
$image = "";
}
echo $image . "
";*/
$image = urldecode($result->edmPreview[0]);
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter,
false,
$image
);
}
}
}
}
\ No newline at end of file
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