From aabbeef743b1d9c15d151d485e14d0e6137d824f Mon Sep 17 00:00:00 2001 From: Dag Date: Wed, 21 Sep 2022 22:20:51 +0200 Subject: [PATCH] docs: add a better bridge example in readme (#3057) --- README.md | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7b592483..d53bff36 100644 --- a/README.md +++ b/README.md @@ -101,28 +101,53 @@ modify the `repository` in `scalingo.json`. See https://github.com/RSS-Bridge/rs Learn more in [Installation](https://rss-bridge.github.io/rss-bridge/For_Hosts/Installation.html). -### Create a bridge +### Create a new bridge from scratch -Create the new bridge in e.g. `bridges/ExecuteBridge.php`: +Create the new bridge in e.g. `bridges/BearBlogBridge.php`: ```php posts as $post) { - $this->items[] = [ - 'uri' => sprintf('https://www.executeprogram.com/blog/%s', $post->slug), - 'title' => $post->title, - 'content' => $post->body, + // An array of dom nodes + $blogPosts = $dom->find('.blog-posts li'); + + foreach ($blogPosts as $blogPost) { + // Select the anchor at index 0 (the first anchor found) + $a = $blogPost->find('a', 0); + + // Select the inner text of the anchor + $title = $a->innertext; + + // Select the href attribute of the anchor + $url = $a->href; + + // Select the