-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (26 loc) · 997 Bytes
/
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
// Modules
const request = require('request')
const cheerio = require('cheerio')
// KickassTorrents base URL
let kickasstorrentsURL = 'https://kat.proxyninja.org'
module.exports = {
search: function(keyword, cb) {
let torrents = []
var reqURL = kickasstorrentsURL + '/search/' + keyword + '/?sortby=seeders&sort=asc'
request(reqURL, function(err, res, body) {
var $ = cheerio.load(body)
$('table.table2 tr').each(function(index, el) {
var torrent = {}
torrent.name = $(this).find('td.tdleft .tt-name a:nth-child(2)').text()
torrent.size = $(this).find('td.tdnormal:nth-child(3)').text()
torrent.seeders = $(this).find('td.tdseed').text()
torrent.leechers = $(this).find('td.tdleech').text()
torrent.url = kickasstorrentsURL + $(this).find('td.tdleft .tt-name a:nth-child(2)').attr('href')
if (torrent.name !== '') {
torrents.push(torrent)
}
})
return cb(null, torrents)
})
}
}