Skip to content

Instantly share code, notes, and snippets.

@rizqyhi
Last active November 2, 2016 06:21
Show Gist options
  • Save rizqyhi/270fb4ce9daeaf456351 to your computer and use it in GitHub Desktop.
Save rizqyhi/270fb4ce9daeaf456351 to your computer and use it in GitHub Desktop.

Naruto Scrapper

A small script to collect direct download link of Naruto. Its easier and more efficient rather than browse through the site episode by episode, then find a link to the download site, and messing with their super annoying auto-popup-ads. Thank you to the site's owner he made the permalink well organized so we don't need to search it first. Also rocks SF because they don't required us to enter captcha, click generate-link-button, etc. :)

First, we need a scrapper package, Goutte. Install it with composer:

composer require "fabpot/goutte:2.*"

Then simply put the scrapper.php inside the directory where you run the composer command.

To get a download link for an episode, simply run php scrapper.php [episode]. E.g.

php scrapper.php 333

Voila! You've got the link and you should be know what to do next. :)

Notes: It works as long it has the same permalink patern

Hint: You can simply generate links for a range of episodes by

<?php
require 'vendor/autoload.php';
$anime_link = "http://www.naruchigo.com/naruto-shippuden-episode-{$argv[1]}-subtitle-bahasa-indonesia/";
// make a new client
$client = new Goutte\Client();
// request the webpage
$anime_page = $client->request('GET', $anime_link);
$link_to_download = $anime_page->filter('.entry-content a[href*="solidfiles"]')->eq(1)->attr('href');
// request download page
$download_page = $client->request('GET', $link_to_download);
$download_link = $download_page->filter('a#ddl-btn')->first()->attr('href');
print $download_link;
exit;
<?php
require 'vendor/autoload.php';
$anime_link = "http://www.naruchigo.com/naruto-shippuden-episode-{$argv[1]}-subtitle-indonesia/";
// make a new client
$client = new Goutte\Client();
// request the webpage
$anime_page = $client->request('GET', $anime_link);
$link_to_download = $anime_page->selectLink('SF')->eq(2)->link();
// request download page
$download_page = $client->request('GET', $link_to_download->getUri());
preg_match('/"download_url": ?"(.*?)"/', $download_page->html(), $result);
echo $result[1]."\n";
exit;
@rizqyhi
Copy link
Author

rizqyhi commented Nov 2, 2016

Update 11/02/2016.

SF has redesigned their download page. They put the download link in a JS object at the bottom of the page. A simple regex would do that. :)
Check out the scrapper_v2.php.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment