summaryrefslogtreecommitdiff
path: root/examples/multiple_starting_urls.js
diff options
context:
space:
mode:
authorrafiramadhana <rf.ramadhana@gmail.com>2023-11-16 05:36:22 +0700
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-11-15 23:48:30 +0100
commit3e01902887bdc52e743ef6cec53a5c89cb5637f0 (patch)
tree607f77cf8b9b00ab73e1003331eebefae7abc9ae /examples/multiple_starting_urls.js
parentbeadfd1db3d2398b9b1e66d60779a7b2649af044 (diff)
Update documentation
Diffstat (limited to 'examples/multiple_starting_urls.js')
-rw-r--r--examples/multiple_starting_urls.js25
1 files changed, 25 insertions, 0 deletions
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"),
+ };
+ }),
+ };
+}