mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-31 15:30:01 +02:00
[FabBridge] Use prefetched JSON data
This commit is contained in:
parent
71396becd6
commit
33631b3863
1 changed files with 12 additions and 26 deletions
|
@ -10,45 +10,31 @@ class FabBridge extends BridgeAbstract
|
|||
|
||||
public function collectData()
|
||||
{
|
||||
|
||||
$responseheaders = get_headers(static::URI);
|
||||
|
||||
$csrf = "";
|
||||
foreach($responseheaders as $entry) {
|
||||
if (str_contains($entry, "Cookie")) {
|
||||
$csrf = explode(":", $entry)[1];
|
||||
$csrf = explode(";", $csrf)[0];
|
||||
}
|
||||
}
|
||||
|
||||
$url = static::URI . '/i/listings/search?is_discounted=1&is_free=1';
|
||||
$url = static::URI . '/limited-time-free';
|
||||
|
||||
$header = [
|
||||
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0',
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: en',
|
||||
'Accept-Encoding: gzip, deflate, br, zstd',
|
||||
'Cookie: ' . $csrf,
|
||||
'Referer: ' . static::URI
|
||||
];
|
||||
|
||||
$json = getContents($url, $header);
|
||||
$json = json_decode($json);
|
||||
$html = getSimpleHTMLDOM($url, $header);
|
||||
$json = $html->find('#js-json-data-prefetched-data');
|
||||
$json = Json::decode($json[0]->innertext);
|
||||
$json = $json['/i/blades/free_content_blade'];
|
||||
|
||||
foreach ($json->results as $item) {
|
||||
$thumbnail = $item->thumbnails[0]->mediaUrl;
|
||||
foreach ($json['tiles'] as $tile) {
|
||||
$item = $tile['listing'];
|
||||
$thumbnail = $item['thumbnails'][0]['mediaUrl'];
|
||||
$itemurl = static::URI . '/listings/' . $item->uid;
|
||||
|
||||
$itemapiurl = static::URI . '/i/listings/' . $item->uid;
|
||||
$itemjson = getContents($itemapiurl, $header);
|
||||
$itemjson = json_decode($itemjson);
|
||||
|
||||
|
||||
$this->items[] = [
|
||||
'title' => $item->title,
|
||||
'author' => $item->user->sellerName,
|
||||
'title' => $item['title'],
|
||||
'author' => $item['user']['sellerName'],
|
||||
'uri' => $itemurl,
|
||||
'timestamp' => strtotime($item->lastUpdatedAt),
|
||||
'content' => '<a href="' . $itemurl . '"><img src="' . $thumbnail . '"></a>' . $itemjson->description,
|
||||
'content' => '<a href="' . $itemurl . '"><img src="' . $thumbnail . '"></a>' . $item['description']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue