repl.it
@426729/

URL List

Express

No description

fork
loading
Files
  • index.js
  • db.js
  • db.sqlite3
  • index.html
  • Packager files
  • package-lock.json
  • package.json
index.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
const bodyParser = require('body-parser');
const db = require('./db');
const request=require('request-promise');
const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(express.static('public'));

let list=[];

app.get('/', (req, res) => {
	res.sendFile(__dirname+"/index.html");
});
app.get('/api',(req,res)=>{
  res.send(list);
});
app.get('/api/post',async (req,res)=>{
  let url=req.query.url;
  if(!list.includes(url)) {
    let toQuery;
    const re=/\.(me|tech|com|website|io)$/;
    const extension=url.match(re);
    let form;
    if(extension){
      toQuery="https://nc.me/search";
      form={term:url.replace(re,""),extension:extension[0]};
    }
    else {
      toQuery="https://www.namecheap.com/domains/registration/results.aspx";
      form={domain:url};
    }

    const options={
      uri:toQuery,
      form,
      transform:html=>cheerio.load(html)
    };

    const $=await request(options);
    const link=$(`${extension?".domain-name":"h2"}[text='${url}']`);
    if(link){

    } else {
      list[url]=
    }
    
    list.push(url);
  }
  res.redirect('/');
});

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