diff options
Diffstat (limited to 'examples/multiple_starting_urls.js')
| -rw-r--r-- | examples/multiple_starting_urls.js | 25 |
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"), + }; + }), + }; +} |