2017-03-27 21:18:16 +03:00
|
|
|
<?php
|
|
|
|
class EtsyBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
const NAME = 'Etsy search';
|
|
|
|
const URI = 'https://www.etsy.com';
|
|
|
|
const DESCRIPTION = 'Returns feeds for search results';
|
|
|
|
const MAINTAINER = 'logmanoriginal';
|
|
|
|
const PARAMETERS = array(
|
|
|
|
array(
|
|
|
|
'query' => array(
|
|
|
|
'name' => 'Search query',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
'title' => 'Insert your search term here',
|
2022-03-24 13:59:34 +03:00
|
|
|
'exampleValue' => 'lamp'
|
2017-03-27 21:18:16 +03:00
|
|
|
),
|
|
|
|
'queryextension' => array(
|
|
|
|
'name' => 'Query extension',
|
|
|
|
'type' => 'text',
|
2018-10-20 14:08:03 +03:00
|
|
|
'required' => false,
|
2017-03-27 21:18:16 +03:00
|
|
|
'title' => 'Insert additional query parts here
|
|
|
|
(anything after ?search=<your search query>)',
|
|
|
|
'exampleValue' => '&explicit=1&locationQuery=2921044'
|
|
|
|
),
|
2022-03-29 23:23:14 +03:00
|
|
|
'hideimage' => array(
|
|
|
|
'name' => 'Hide image in content',
|
2017-03-27 21:18:16 +03:00
|
|
|
'type' => 'checkbox',
|
2022-03-29 23:23:14 +03:00
|
|
|
'title' => 'Activate to hide the image in the content',
|
2017-03-27 21:18:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
public function collectData(){
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
2017-03-27 21:18:16 +03:00
|
|
|
|
2022-03-29 23:23:14 +03:00
|
|
|
$results = $html->find('li.wt-list-unstyled');
|
2017-03-27 21:18:16 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($results as $result) {
|
2022-03-29 23:23:14 +03:00
|
|
|
// Remove Lazy loading
|
|
|
|
if($result->find('.wt-skeleton-ui', 0))
|
2017-03-27 21:18:16 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
$item = array();
|
|
|
|
|
|
|
|
$item['title'] = $result->find('a', 0)->title;
|
|
|
|
$item['uri'] = $result->find('a', 0)->href;
|
2022-03-29 23:23:14 +03:00
|
|
|
$item['author'] = $result->find('p.wt-text-gray > span', 2)->plaintext;
|
2017-03-27 21:18:16 +03:00
|
|
|
|
|
|
|
$item['content'] = '<p>'
|
2018-10-20 14:08:03 +03:00
|
|
|
. $result->find('span.currency-symbol', 0)->plaintext
|
2022-03-29 23:23:14 +03:00
|
|
|
. $result->find('span.currency-value', 0)->plaintext
|
2017-03-27 21:18:16 +03:00
|
|
|
. '</p><p>'
|
2018-10-20 14:08:03 +03:00
|
|
|
. $result->find('a', 0)->title
|
2017-03-27 21:18:16 +03:00
|
|
|
. '</p>';
|
|
|
|
|
2022-03-29 23:23:14 +03:00
|
|
|
$image = $result->find('img.wt-display-block', 0)->src;
|
2017-03-27 21:18:16 +03:00
|
|
|
|
2022-03-29 23:23:14 +03:00
|
|
|
if(!$this->getInput('hideimage')) {
|
2017-03-27 21:18:16 +03:00
|
|
|
$item['content'] .= '<img src="' . $image . '">';
|
|
|
|
}
|
|
|
|
|
|
|
|
$item['enclosures'] = array($image);
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!is_null($this->getInput('query'))) {
|
2017-03-27 21:18:16 +03:00
|
|
|
$uri = self::URI . '/search?q=' . urlencode($this->getInput('query'));
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!is_null($this->getInput('queryextension'))) {
|
2017-03-27 21:18:16 +03:00
|
|
|
$uri .= $this->getInput('queryextension');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getURI();
|
|
|
|
}
|
|
|
|
}
|