From 6d36fb181b883bae5ebf68d2e36798b8a55bfa68 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sun, 27 Jul 2025 14:48:18 +0200 Subject: [PATCH] =?UTF-8?q?Neue=20Bridge=20f=C3=BCr=20Dubesors=20LLM=20Ben?= =?UTF-8?q?chmark=20Blog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DubesorBridge.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 DubesorBridge.php diff --git a/DubesorBridge.php b/DubesorBridge.php new file mode 100644 index 0000000..9137067 --- /dev/null +++ b/DubesorBridge.php @@ -0,0 +1,75 @@ +getURI(); + $html = getSimpleHTMLDOM($pageUrl) + or returnServerError('Could not request webpage: ' . $pageUrl); + + foreach ($html->find('.entry') as $element) { + if (count($this->items) >= 20) { + break; + } + + $modelTagsContainer = $element->find('.model-tags-container', 0); + $dateElement = $element->find('.entry-date', 0); + $contentElement = $element->find('.entry-content', 0); + + if (!$modelTagsContainer || !$dateElement || !$contentElement) { + continue; + } + + $modelTags = $modelTagsContainer->find('.model-tag'); + $modelNames = array(); + foreach ($modelTags as $tag) { + $modelNames[] = trim(strip_tags($tag->innertext)); + } + + if (empty($modelNames)) { + continue; + } + + $dateStr = trim(strip_tags($dateElement->innertext)); + $content = $contentElement->innertext; + + $timestamp = strtotime($dateStr); + $modelList = implode(', ', $modelNames); + $title = 'First Impression: ' . $modelList; + + $anchorLink = $modelTagsContainer->find('.anchor-link', 0); + $anchorId = ''; + if ($anchorLink) { + $href = $anchorLink->href; + $anchorId = str_replace('#', '', $href); + } else { + $anchorId = strtolower(str_replace(' ', '-', $modelNames[0])); + $anchorId = preg_replace('/[^a-z0-9\-]/', '', $anchorId); + } + + $uri = $this->getURI() . '#' . $anchorId; + + $item = array(); + $item['uid'] = $uri; + $item['uri'] = $uri; + $item['title'] = $title; + $item['content'] = $content; + $item['timestamp'] = $timestamp; + $item['author'] = 'Dubesor'; + + $this->items[] = $item; + } + } +}