Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
MetaGer
Commits
0bed9200
Commit
0bed9200
authored
Apr 24, 2019
by
Aria Givi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loadnext is working now
parent
f10a307a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
4 deletions
+52
-4
app/Models/parserSkripte/Kelkoo.php
app/Models/parserSkripte/Kelkoo.php
+51
-3
app/Models/parserSkripte/Mg_produkt2.php
app/Models/parserSkripte/Mg_produkt2.php
+1
-1
No files found.
app/Models/parserSkripte/Kelkoo.php
View file @
0bed9200
...
...
@@ -8,11 +8,14 @@ use Log;
class
Kelkoo
extends
Searchengine
{
public
$results
=
[];
public
$unsignedGetString
=
""
;
public
function
__construct
(
$name
,
\
StdClass
$engine
,
\
App\MetaGer
$metager
)
{
parent
::
__construct
(
$name
,
$engine
,
$metager
);
$this
->
getString
=
$this
->
UrlSigner
();
$this
->
unsignedGetString
=
$this
->
getString
;
$this
->
getString
=
$this
->
UrlSigner
(
$this
->
unsignedGetString
);
# var_dump($this->getString);
$this
->
hash
=
md5
(
$this
->
engine
->
host
.
$this
->
getString
.
$this
->
engine
->
port
.
$this
->
name
);
}
...
...
@@ -20,6 +23,8 @@ class Kelkoo extends Searchengine
public
function
loadResults
(
$result
)
{
$result
=
preg_replace
(
"/
\r\n
/si"
,
""
,
$result
);
# var_dump($result);
# die();
# delete namespace, allowing easier xpath access
$result
=
str_replace
(
'xmlns="urn:yahoo:prods"'
,
''
,
$result
);
try
{
...
...
@@ -78,13 +83,56 @@ class Kelkoo extends Searchengine
public
function
getNext
(
\
App\MetaGer
$metager
,
$result
)
{
$result
=
preg_replace
(
"/
\r\n
/si"
,
""
,
$result
);
# delete namespace, allowing easier xpath access
$result
=
str_replace
(
'xmlns="urn:yahoo:prods"'
,
''
,
$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
;
}
# Kekloo gives us the total Result Count
$resultCount
=
$content
->
xpath
(
'/ProductSearch/Products/@totalResultsAvailable'
);
if
(
sizeof
(
$resultCount
)
>
0
)
{
$resultCount
=
intval
(
$resultCount
[
0
]
->
__toString
());
}
else
{
$resultCount
=
0
;
}
$this
->
totalResults
=
$resultCount
;
// 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
>=
(
$this
->
totalResults
-
20
))
{
return
;
}
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$next
=
new
Kelkoo
(
$this
->
name
,
$this
->
engine
,
$metager
);
$next
->
unsignedGetString
.
=
"&start="
.
(
$current
+
20
);
$next
->
getString
=
$next
->
UrlSigner
(
$next
->
unsignedGetString
);
$next
->
hash
=
md5
(
$next
->
engine
->
host
.
$next
->
getString
.
$next
->
engine
->
port
.
$next
->
name
);
$this
->
next
=
$next
;
}
# kelkoogroup.com/kelkoo-customer-service/kelkoo-developer-network/shopping-services/samples/signing-url-php/
p
rivate
function
UrlSigner
(){
p
ublic
function
UrlSigner
(
$path
){
$urlPath
=
$th
is
->
getString
;
$urlPath
=
$
pa
th
;
$partner
=
$this
->
engine
->
{
"http-auth-credentials"
}
->
ID
;
$key
=
$this
->
engine
->
{
"http-auth-credentials"
}
->
Key
;
...
...
app/Models/parserSkripte/Mg_produkt2.php
View file @
0bed9200
...
...
@@ -32,7 +32,7 @@ class Mg_produkt2 extends Searchengine
$link
=
$result
->
xpath
(
'/doc/arr[@name="artikelDeeplink"]'
)[
0
]
->
{
"str"
}
->
__toString
();
$anzeigeLink
=
parse_url
(
$link
);
parse_str
(
$anzeigeLink
[
'query'
],
$query
);
$anzeigeLink
=
$query
[
'url'
];
$anzeigeLink
=
$query
[
'
di
url'
];
$descr
=
$result
->
xpath
(
'/doc/arr[@name="artikelBeschreibung"]'
)[
0
]
->
{
"str"
}
->
__toString
();
$image
=
$result
->
xpath
(
'/doc/arr[@name="artikelImageurl"]'
)[
0
]
->
{
"str"
}
->
__toString
();
$this
->
counter
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment