From 3e01902887bdc52e743ef6cec53a5c89cb5637f0 Mon Sep 17 00:00:00 2001 From: rafiramadhana Date: Thu, 16 Nov 2023 05:36:22 +0700 Subject: Update documentation --- examples/multiple_starting_urls.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/multiple_starting_urls.js (limited to 'examples') diff --git a/examples/multiple_starting_urls.js b/examples/multiple_starting_urls.js new file mode 100644 index 0000000..5cb7ac9 --- /dev/null +++ b/examples/multiple_starting_urls.js @@ -0,0 +1,25 @@ +export const config = { + urls: [ + "https://news.ycombinator.com/show", + "https://news.ycombinator.com/ask", + ], +}; + +export default function({ doc, absoluteURL }) { + const posts = doc.find(".athing"); + + return { + posts: posts.map((post) => { + const link = post.find(".titleline > a"); + const meta = post.next(); + + return { + url: absoluteURL(link.attr("href")), + user: meta.find(".hnuser").text(), + title: link.text(), + points: meta.find(".score").text().replace(" points", ""), + created: meta.find(".age").attr("title"), + }; + }), + }; +} -- cgit v1.2.3