A JavaScript webscraper which tries to get lyrics from a simple google search.
- Proper use of an artist's lyrics in relation to copyright laws is the users' responsiblity. Respect artist's copyrights.
- Because this is a screen-scraper the parsing of Google's search results is brittle and relies on a specific DOM structure. If you rely on this module, keep an eye out on whether it continues to work.
$ npm install google-lyrics
The package installs the script google-lyrics
into your path, so you can do:
$ google-lyrics -f json "row row row your boat"
google-lyrics "row row row your boat"
[
"Row, row, row your boat",
"Gently down the stream",
"Merrily merrily, merrily, merrily",
"Life is but a dream",
"",
"",
"Row, row, row your boat",
"Gently down the stream",
"Merrily merrily, merrily, merrily",
"Life is but a dream",
"",
"",
"Row, row, row your boat",
"Gently down the stream",
"Merrily merrily, merrily,",
"",
"",
"Row, row, row your boat",
"Gently down the stream",
"Merrily merrily, merrily, merrily",
"Life is but a dream",
"",
"",
"Row, row, row your boat",
"Gently down the stream",
"Merrily merrily, merrily, merrily",
"Life is but a dream"
]
To output text, pass text
with the -f
option, or don't invoke the script with -f
.
You can also use as a module in another node script:
const { search } = require("google-lyrics");
search("row row row your boat", "json").then(lyrics => console.log(lyrics));
You can also import from google-lyrics
getGeneratedSource
, which takes a search term as a parameter and returns
a promise with the JavaScript generated source from google and parseSource
which takes the generated HTML from getGeneratedSource
and parses into JSON.