Skip to content

Latest commit

 

History

History
63 lines (53 loc) · 1.8 KB

README.md

File metadata and controls

63 lines (53 loc) · 1.8 KB

google-lyrics

A JavaScript webscraper which tries to get lyrics from a simple google search.

Caveats

  • 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.

Install

$ npm install google-lyrics

CLI

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.

As Module

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.