The Pirate Bay Scraper / Bot

18 07 2009
Screen show of the scraper in action

Screen shot of the scraper in action!

I heard the news - The Pirate Bay has been purchased for $7.7 Million. So, I decided it would be a cool idea to scrape all the torrent files and archive them. Long story short - I coded a PHP / MySQL scraper that just follows links on TPB and downloads Torrents as it find them. It is pretty simple.

This fantastic package can be yours right now for a small donation *hint hint wink wink*. Not really, but it would be nice ;)

I did have the scrapers live stats up, but my hosting company wont let me. The script also has a nifty search / download page:

Thanks!

UPDATE:
You can download a .rar file from my site here, or you can help spread the work by downloading it via bit-torrent from The Pirate Bay.

Description From TPB:
The Pirate Bay Torrent Scraper

**This is Version 1.1**
* Fixed MySQL connections issue. MySQL now closes connections correctly.

*View Live working demo at http://iluvjohn.com/scripts/tpb/torrent.php

I will be Seeding for a long time….only 2.93 MB!

IMPORTANT NOTE:
In torrent.php there are 2 urls you need to change so that you don’t go to my site.
just strip out “http://iluvjohn.com/scripts/tpb/” and you should be fine.
Sorry about that…..didn’t realize it at first.

This is a script I have been writing for about 2 days now. I figured since TPB got bought, we should ensure ourselves access to the torrents the we the people have taken the time to create.

This script requires PHP, MySQL and Curl.

This script comes with:

*An install.php file that will set up your database.
*index.php will scan and scrape TPB for torrents, following links much like a bot does.
*index.php will save .torrent files that originate from torrents.thepiratebay.org only.
*When index.php finds a torrent it checks to make sure its not already in the DB, Saves the Torrent file in the DB, saves the URL in which the torrent was located, and saves the entire page that the torrent file was found on (preserving the description / info of the torrent file).

*torrents.php file will allow anyone to see the stats of the scraper, as well as search through torrent names and download torrent files.

*If people like this script, I’d consider releasing updates. If you want to add to it / mod it, by all means go for it!! Feel free to send it to me to check out too!!

I feel there is a bit of a press for time regarding TPB, so I wanted to get this out there ASAP, even if it is a little bit crude.

I have tested this on windows and linux servers. If you are planning on running it from home, I suggest dedicating an entire whole computer to this - It will take a bit of HD space, and also processing will start to rise drastically as the database fills up as this app is primarily database driven.

Contact me via: http://iluvjohn.com/contact.php

Or comment for others (if you really like the script) here: http://iluvjohn.com/2009/07/18/the-pirate-bay-scraper-bot/

Written by: John Minton



PHP isset() vs empty()

10 05 2009

One of my first websites used sessions to validate user login. I used a very basic include system and for the most part it seamed to work really well.

Then one day the login stopped working correctly. A friend mentioned to me that the SESSION might be buggy when validating that the user is logged in or not. He explained that if I was using

<?php
if(!empty($_SESSION['userid'])){
// logged in page here
}else{
//not logged in page here
}
?>

that I should try using

<?php
if(isset($_SESSION['userid'])){
// logged in page here
}else{
//not logged in page here
}
?>

and vice-versa.

For years I have not figured out exactly what that was. But now after searching for an answer I found an interesting issue in the PHP forums: The different between the PHP functions empty() and isset().

At first I thought it was only a few people and that someone had set them straight. But I was wrong! Hundreds, it seamed, of people who where asking the same question over and over and over again were getting the wrong answer just as much. Not even one person had posted an answer that was close to where my mind was.

Here is the low-down on these two functions, isset() and empty().

Here is an example of isset()’s intended usage:

<?php
$var = "asdf"; // set var, equales a string
$var = ""; // empty out the variable
if(isset($var)){echo "var isset";}else{echo "var is not set";}
echo "<br /><br />";
$var2 = ""; // set an empty variable
if(isset($var)){echo "var2 isset";}else{echo "var2 is not set";}
echo "<br /><br />";
$unsetvar = "Unset me"; // set a variable with a string.
unset($unsetvar); // destroy the variable.
if(isset($unsetvar)){echo "unsetvar isset";}else{echo "unsetvar is not set";}
echo "<br /><br />";
if(isset($this_is_not_here)){echo "this_is_not_here isset";}else{echo "this_is_not_here is not set";}
?>

This will output the following:

var isset

var2 isset

unsetvar is not set

this_is_not_here is not set

You can plainly see that even the empty variables will still pass isset(), while they would not pass !empty().

To say it is simply:
When you set a variable in PHP it “opens it up”, or sets aside a space in the memory for it.

isset() determines if a variable has a place emptied out in memory for it. In other words, it wants to see if the variable has been set.

At the same time, if a variable is !empty() then it is isset(), and the two are the one in the same.

You can see how some applications can use either. In my opinion, unless needed otherwise it is probably best to stick with the empty() function. I wouldn’t be able to tell you for sure how or why, it’s more like a guy feeling I have…. But I could be totally wrong.

The difference between isset() and empty() is that isset() checks to see if a variable has been used even if it is empty, while empty() just checks the state of the contents of the variable.

You can cause a variable tat is set to be completely removed from the memory by using unset($var). If you unset() a variable and then check it with isset(), it will return false as unset() completely removes any traces of the variable.

Questions? Comments? Can’t figure something out? Email me on the contact form or leave a comment!

Written by: John Minton



Yuwie.Com Bot - Friend Adder, Auto Comment

24 02 2009

I am selling a bot I made for Yuwie.com.

I personally don’t agree with the way that Yuwie operates….They do not return emails, they don’t answer your quetions, horrible customer service, and they claim you can make all this money but then for any reason they can close your account and not pay you. Therefore you will not ever make it to the top because it takes one person to say you did something wrong and you are out of the picture. Also, they censor what you say. So you can see how easy it is to become fed up with their BS….

Back to the point here. I made a bot for yuwie.com. Here are the features:

  • Login to your yuwie.com account
  • Add friends / Send friende requests with custom comments
  • Comment all friends on your friends list with custom comments and/or graphics.
  • Currently I have it pull picture comments from YuwieX.Com, a comment graphic website of my own, and comment all friends on my list.
  • Is not stopped by CAPTCHAs

It is easy with this tool to get well over 1,000 page views a day. It took me not more than a week to work up to 4,000 friends.

If you are interested send me a message on the contact form and we can work something out.

Thanks!

Written by: John Minton