2019-06-01 12:18:30 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-01 12:18:30 +03:00
|
|
|
class BinanceBridge extends BridgeAbstract
|
|
|
|
{
|
2022-04-06 00:20:27 +03:00
|
|
|
const NAME = 'Binance Blog';
|
|
|
|
const URI = 'https://www.binance.com/en/blog';
|
|
|
|
const DESCRIPTION = 'Subscribe to the Binance blog.';
|
2019-06-01 12:18:30 +03:00
|
|
|
const MAINTAINER = 'thefranke';
|
|
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-01 12:18:30 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://bin.bnbstatic.com/static/images/common/favicon.ico';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-04-06 00:20:27 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDOM(self::URI)
|
|
|
|
or returnServerError('Could not fetch Binance blog data.');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-07-29 19:55:36 +03:00
|
|
|
$appData = $html->find('script[id="__APP_DATA"]');
|
|
|
|
$appDataJson = json_decode($appData[0]->innertext);
|
2022-09-25 20:19:35 +03:00
|
|
|
$allposts = $appDataJson->routeProps->f3ac->blogListRes->list;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-09-25 20:19:35 +03:00
|
|
|
foreach ($allposts as $element) {
|
|
|
|
$date = $element->releasedTime;
|
2021-07-29 19:55:36 +03:00
|
|
|
$title = $element->title;
|
2022-09-25 20:19:35 +03:00
|
|
|
$category = $element->category->name;
|
|
|
|
|
|
|
|
$suburl = strtolower($category);
|
|
|
|
$suburl = str_replace(' ', '_', $suburl);
|
|
|
|
|
|
|
|
$uri = self::URI . '/' . $suburl . '/' . $element->idStr;
|
|
|
|
|
|
|
|
$contentHTML = getSimpleHTMLDOMCached($uri);
|
|
|
|
$contentAppData = $contentHTML->find('script[id="__APP_DATA"]');
|
|
|
|
$contentAppDataJson = json_decode($contentAppData[0]->innertext);
|
|
|
|
$content = $contentAppDataJson->routeProps->a106->blogDetail->content;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-01 12:18:30 +03:00
|
|
|
$item = [];
|
|
|
|
$item['title'] = $title;
|
|
|
|
$item['uri'] = $uri;
|
2021-07-29 19:55:36 +03:00
|
|
|
$item['timestamp'] = substr($date, 0, -3);
|
2019-06-01 12:18:30 +03:00
|
|
|
$item['author'] = 'Binance';
|
|
|
|
$item['content'] = $content;
|
2022-09-25 20:19:35 +03:00
|
|
|
$item['categories'] = $category;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-01 12:18:30 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2019-06-01 12:18:30 +03:00
|
|
|
if (count($this->items) >= 10) {
|
|
|
|
break;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-06-01 12:18:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|