Created
February 12, 2021 09:28
-
-
Save Akifcan/72acad176cd4164cc8c14d186afd600e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio') | |
const axios = require('axios') | |
async function searchSong(id, artistname, song) { | |
artistname = artistname.replace(/ /g, '+') | |
song = song.replace(/ /g, '+') | |
const response = await axios.get(`https://www.lyrics.com/lyric/${id}/${artistname}/${song}`) //sayfa kaynak kodunu alıyoruz | |
const $ = cheerio.load(response.data) // ve kaynak kodunu cheerioya yüklüyoruz | |
const lyrcis = $('.lyric-body').text(); //az önce tarayıcı konsolunda cevabını aldığımız .lyric-body sınıfını uygulamamızdan aratıyoruz | |
const songName = $('#lyric-title-text').text() | |
const artist = $('.lyric-artist a:not(:last-child)').text() | |
return { | |
lyrcis, songName, artist | |
} | |
} | |
searchSong('35855210', 'alan walker', 'darkside') | |
.then(response => { | |
console.log(response); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment