@jajoosam/

scrape

Express

No description

fork
loading
Files
  • index.js
  • package-lock.json
  • package.json

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.659996658114909","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Y29uc3QgZXhwcmVzcyA9IHJlcXVpcmUoJ2V4cHJlc3MnKTsKY29uc3QgYXhpb3MgPSByZXF1aXJlKCdheGlvcycpCnZhciBwcmV0dHkgPSByZXF1aXJlKCdleHByZXNzLXByZXR0aWZ5Jyk7CnZhciBqc29uc3RvcmUgPSByZXF1aXJlKCdqc29uc3RvcmUuaW8nKQoKCmNvbnN0IGFwcCA9IGV4cHJlc3MoKTsKYXBwLnVzZShleHByZXNzLnN0YXRpYygncHVibGljJykpOwphcHAudXNlKHByZXR0eSh7IHF1ZXJ5OiAncHJldHR5JyB9KSk7CgpsZXQgc3RvcmUgPSBuZXcganNvbnN0b3JlKHByb2Nlc3MuZW52LkRCKQoKCmFwcC5nZXQoJy8nLCAocmVxLCByZXMpID0+IHsKICByZXMuc2VuZChgeW8gaXQncyBhbGwgYXQgL2ZldGNoYCkKfSk7CgphcHAuZ2V0KCcvZmV0Y2gnLCAocmVxLCByZXMpID0+IHsKICB2YXIgaW5Ub2tlbiA9IHJlcS5xdWVyeS50b2tlbgogIHN0b3JlLnJlYWQoaW5Ub2tlbikudGhlbiggKGRhdGEpID0+IHsKICAgIGlmKChkYXRhPDEwMDApKXsKICAgICAgcmVxLnF1ZXJ5LnRva2VuID0gcHJvY2Vzcy5lbnYuVE9LRU47CiAgICAgIHZhciBxdWVyeVN0cmluZyA9IE9iamVjdC5rZXlzKHJlcS5xdWVyeSkubWFwKGtleSA9PiBrZXkgKyAnPScgKyByZXEucXVlcnlba2V5XSkuam9pbignJicpOwogICAgICBheGlvcy5nZXQoYGh0dHBzOi8vcGFnZS5yZXN0L2ZldGNoPyR7cXVlcnlTdHJpbmd9YCkKICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlc3BvbnNlKSB7CiAgICAgICAgcmVzLnNlbmQocmVzcG9uc2UuZGF0YSk7CiAgICAgIH0pCiAgICAgIC5jYXRjaChmdW5jdGlvbiAoZXJyb3IpIHsKICAgICAgICByZXMuc2VuZChgc29tZXRoaW5nIHdlbnQgd3JvbmdgKQogICAgICB9KTsKICAgICAgc3RvcmUud3JpdGUoaW5Ub2tlbiwgZGF0YSsxKQogICAgfQogICAgZWxzZXsKICAgICAgcmVzLnNlbmQoYGJydWggd2hhdGApCiAgICB9CiAgfSkKfSk7CgphcHAubGlzdGVuKDMwMDAsICgpID0+IGNvbnNvbGUubG9nKCdzZXJ2ZXIgc3RhcnRlZCcpKTs="},"asBuffer":null},"loaded":true}}
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
34
35
36
37
38
39
const express = require('express');
const axios = require('axios')
var pretty = require('express-prettify');
var jsonstore = require('jsonstore.io')


const app = express();
app.use(express.static('public'));
app.use(pretty({ query: 'pretty' }));

let store = new jsonstore(process.env.DB)


app.get('/', (req, res) => {
  res.send(`yo it's all at /fetch`)
});

app.get('/fetch', (req, res) => {
  var inToken = req.query.token
  store.read(inToken).then( (data) => {
    if((data<1000)){
      req.query.token = process.env.TOKEN;
      var queryString = Object.keys(req.query).map(key => key + '=' + req.query[key]).join('&');
      axios.get(`https://page.rest/fetch?${queryString}`)
      .then(function (response) {
        res.send(response.data);
      })
      .catch(function (error) {
        res.send(`something went wrong`)
      });
      store.write(inToken, data+1)
    }
    else{
      res.send(`bruh what`)
    }
  })
});

app.listen(3000, () => console.log('server started'));