summaryrefslogtreecommitdiff
path: root/examples/coinmarketcap.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/coinmarketcap.js')
-rw-r--r--examples/coinmarketcap.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/coinmarketcap.js b/examples/coinmarketcap.js
new file mode 100644
index 0000000..7693fd8
--- /dev/null
+++ b/examples/coinmarketcap.js
@@ -0,0 +1,30 @@
+export const config = {
+ url: "https://coinmarketcap.com/",
+};
+
+export default function({ doc }) {
+ const rows = doc.find(".cmc-table tbody tr");
+
+ return {
+ currencies: rows
+ .map((row) => {
+ const cols = row.find("td");
+
+ return {
+ position: cols.get(1).text(),
+ currency: cols.get(2).find("p").get(0).text(),
+ symbol: cols.get(2).find("p").get(1).text(),
+ price: cols.get(3).text(),
+ change: {
+ "1h": cols.get(4).text(),
+ "24h": cols.get(5).text(),
+ "7dh": cols.get(6).text(),
+ },
+ marketcap: cols.get(7).find("span").get(1).text(),
+ volume: cols.get(8).find("p").get(0).text(),
+ supply: cols.get(9).text(),
+ };
+ })
+ .slice(0, 10),
+ };
+}