Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #requirement
- #if not installed: sudo cpan install Web:Scraper
- #example call:
- perl ./spotify.pl '<iframe src="https://embed.spotify.com/?uri=spotify:track:2qpmEFEoc6bVpYhc4Lp5Uo" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>
- <iframe src="https://embed.spotify.com/?uri=spotify:track:28TcG73tbc4iGrGBFjiBnR" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>'
- //CODE
- use strict;
- use URI;
- use Web::Scraper;
- #init
- my @songs=();
- #scraper
- my $data = scraper {
- # we will save the urls from the teams
- process "ul.track-info>li.track-title", 'titles[]' => 'TEXT';
- process "ul.track-info>li.artist", 'artists[]' => 'TEXT';
- };
- #loop over infput
- foreach ($ARGV[0]=~/<iframe src="(.*)" width="300" height="380" frameborder="0" allowtransparency="true"><\/iframe>/g){
- # scrape the data
- my $res = $data->scrape(URI->new($_));
- push(@songs,$res->{titles}[0] . " " . $res->{artists}[0]);
- }
- print join("\n",@songs),"\n";
- ~
- ~
- ~
- ~
- ~
- ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement