WebService::SongLyrics - Retrieve song lyrics from www.songlyrics.com
use WebService::SongLyrics; my $wsl = WebService::SongLyrics->new; my $lyrics = $wsl->get_lyrics("Beyonce", "Crazy in love");
The WebService::SongLyrics module attempts to scrape song lyrics from http://www.songlyrics.com Due to the nature of screen scraping it's not the most resilient of code.
Thanks to the sites search engine it's a little picky about the phrasing of the song and artist. It especially doesn't like "Artist ft other artist".
use WebService::SongLyrics; my $wsl = WebService::SongLyrics->new; my $lyrics = $wsl->get_lyrics("Beyonce", "Crazy in love"); print $lyrics, "\n" if $lyrics;
This is the constructor for a new WebService::SongLyrics object. It takes no arguments and simply returns a new instance.
The get_lyrics method requires both an artist and a song title and returns the lyrics for the given combination. If it can find them.
get_lyrics
It returns undef if you fail to pass in either parameter or if it can't find the lyrics. It dies with a short message and the URL if the server can't be found or it gets a HTTP status code that indicates failure.
undef
die
I originally planned to release this under the Lyrics::Fetch namespace but after spending some time digging through the (very limited) docs and descriptions I thought it'd be better to do it as a stand-alone module.
The namespace is a little pretentious but it does fit with the other WebService::DomainName modules already on CPAN.
WebService::SongLyrics requires the following modules:
LWP::UserAgent
URI::Escape
Copyright (C) 2006 Dean Wilson. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Dean Wilson <dean.wilson@gmail.com>
To install WebService::SongLyrics, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::SongLyrics
CPAN shell
perl -MCPAN -e shell install WebService::SongLyrics
For more information on module installation, please visit the detailed CPAN module installation guide.