summaryrefslogtreecommitdiff
path: root/examples/coinmarketcap.js
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-10-19 20:43:04 +0200
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-10-19 20:43:04 +0200
commit2bfae5b426bf4a0b99d3979ed12d63cb50c39b17 (patch)
treed1a3c622e9b13e66e16b3e7b96068c67933ad950 /examples/coinmarketcap.js
parent135eff4287c06aff9604a4d0b9ddea1740f6c836 (diff)
Add examples
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),
+ };
+}