-
Notifications
You must be signed in to change notification settings - Fork 0
/
reddit.js
33 lines (30 loc) · 1 KB
/
reddit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export const config = {
url: "https://old.reddit.com/",
};
export default function({ doc, absoluteURL }) {
const posts = doc.find("#siteTable .thing:not(.promoted)");
return {
posts: posts.map((post) => {
const rank = post.find(".rank");
const user = post.find(".author");
const created = post.find("time");
const title = post.find("a.title");
const comments = post.find(".comments");
const subreddit = post.find(".subreddit");
const upvotes = post.find(".score.unvoted");
const thumbnail = post.find("a.thumbnail img");
return {
rank: rank.text(),
user: user.text(),
created: created.attr("datetime"),
title: title.text(),
link: absoluteURL(title.attr("href")),
comments: comments.text().replace(" comments", ""),
comments_link: comments.attr("href"),
subreddit: subreddit.text(),
upvotes: upvotes.text(),
thumbnail: absoluteURL(thumbnail.attr("src")),
};
}),
};
}