forked from ManishKarki1997/torrents-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
80 lines (46 loc) · 1.68 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const cheerio = require('cheerio');
const axios = require('axios');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const torrentsController = require('./controllers/torrentController');
const torrentFeed = require('./controllers/torrentFeed');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
app.use('/api/search', torrentsController);
app.use('/api/feed', torrentFeed);
const PORT = process.env.PORT || 3000;
// const searchTerm = process.argv.slice(2)[0];
// const genre = process.argv.slice(3)[0];
// let searchTerm = '';
// let genre = '';
// const torrentSearchURLs=[]
app.listen(PORT, (err) => {
if (err) {
console.log(err);
}
console.log(`Server running on port ${PORT}`)
})
// async function scrape() {
// const html = await getHTML();
// const $ = cheerio.load(html);
// const torrentsContainer = $('.table-list tbody').html();
// let scrapedResults = []
// $(torrentsContainer).each(function (i, el) {
// const torrentName = $(this).children('td').children('a').eq(1).text();
// let torrentURL = $(this).find('td.name').find('a').eq(1).attr('href');
// const torrentSeeds = $(this).find('td.seeds').text();
// const torrentLeeches = $(this).find('td.leeches').text();
// scrapedResults.push({
// torrentName,
// torrentURL,
// torrentSeeds,
// torrentLeeches
// })
// })
// torrents = scrapedResults.filter(torr => torr.torrentURL !== undefined);
// console.log(torrents)
// }
// scrape();