1. Go to this page and download the library: Download aportela/scraper-lyrics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aportela / scraper-lyrics example snippets
er = new \Psr\Log\NullLogger("");
$cache = null;
// uncomment the following lines for storing into disk cache the lyrics
//$cachePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . "cache";
//$cache = new \aportela\SimpleFSCache\Cache($logger, \aportela\SimpleFSCache\CacheFormat::TXT, $cachePath);
$lyrics = new \aportela\ScraperLyrics\Lyrics($logger, $cache);
/**
Search/Scrap on all providers
*/
if ($lyrics->scrap(
"Bohemian Rhapsody",
"Queen"
)) {
echo sprintf(
"<H1>Title: %s</h1><H2>Artist: %s</H2><H3>Source: %s</H3><PRE>%s</PRE>",
$lyrics->getTitle(),
$lyrics->getArtist(),
$lyrics->getSource(),
$lyrics->getLyrics()
);
}
/**
Search/Scrap on custom scrap providers
You can use this method if at some point in the future a provider stops working and you want to ignore scraping with him (which will give an error) in case you previously used the global (scrap) method
*/
if ($lyrics->scrap(
"Bohemian Rhapsody",
"Queen",
[
\aportela\ScraperLyrics\SourceProvider::SEARCH_ENGINE_DUCKDUCKGO,
\aportela\ScraperLyrics\SourceProvider::MUSIXMATCH
]
)) {
echo sprintf(
"<H1>Title: %s</h1><H2>Artist: %s</H2><H3>Source: %s</H3><PRE>%s</PRE>",
$lyrics->getTitle(),
$lyrics->getArtist(),
$lyrics->getSource(),
$lyrics->getLyrics()
);
}
/**
Search/Scrap on custom source provider
Same as the previous one but for a single source provider
*/
if ($lyrics->scrapFromSourceProvider(
"Bohemian Rhapsody",
"Queen",
\aportela\ScraperLyrics\SourceProvider::SEARCH_ENGINE_DUCKDUCKGO
)) {
echo sprintf(
"<H1>Title: %s</h1><H2>Artist: %s</H2><H3>Source: %s</H3><PRE>%s</PRE>",
$lyrics->getTitle(),
$lyrics->getArtist(),
$lyrics->getSource(),
$lyrics->getLyrics()
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.