donfanning
8/15/2018 - 1:13 PM

Crawler Animes

Crawler Animes

const Crawler = require('crawler')
const baseUrl = 'https://animes.zlx.com.br'
const startUrl = baseUrl+'/exibir/67/6561/shingeki-no-kyojin-01'

const crawler = new Crawler({
    maxConnections: 10,
    skipDuplicates: true,
    callback: (error, response, done) => {
        const $ = response.$
        const title = $('title').text()

        const hd = response.body.match(/http(s)?\:\/\/.*\/HD\/episodios\/[0-9\.]+.mp4/gm)
        const mq = response.body.match(/http(s)?\:\/\/.*\/MQ\/episodios\/[0-9\.]+.mp4/gm)

        console.log(title)

        if (hd) {
            console.log('HD : '+hd[0])
        }

        console.log('MQ : '+mq[0]+"\n")

        done()
    }
})

crawler.queue({
    uri: startUrl,
    callback: (error, response, done) => {
        const $ = response.$

        $('#this-serie-tv > a').each(function () {
            crawler.queue({
                uri: baseUrl + $(this).attr('href'),
                callback: function (error, response, done) {
                    const $ = response.$

                    crawler.queue(baseUrl + $('.video-placeholder iframe').attr('src'))

                    done()
                }
            })
        });

        done()
    }
})