Local

..:: Home
..:: Legal
..:: Contact
..:: About
..:: RSS
..:: Log in

Links

..:: Fake Bill Gates
..:: Tap the Hive

A Random Quote

"Here's to the crazy ones. The misfits. The rebels. The trouble-makers. The round heads in the square holes. The ones who see things differently. They're not fond of rules, and they have no respect for the status-quo. You can quote them, disagree with them, glorify, or vilify them. But the only thing you can't do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do." -- Jack Kerouac

Font Bot

This is a bot designed to crawl 1001freefonts.com pulling all the windows fonts. This was my first bot, and I wasn’t really big in linux admin yet so it’s incredibly crude.

REQUIREMENTS

  • wget: almost every linux distro has it
  • php: most bigger distros have it. check php.net to get it if you dont.

Here’s the code. It’s a little messy, but it works. It’s easiest run as php cgi, but if you want to go through all the hassles of permission, you can execute it with apache.

#!/usr/bin/php
<?
function fontbot($startpage)
{
     if (trim($startpage) == '')
          $startpage = 'http://www.1001freefonts.com/fonts/afonts.htm';
     $url = $startpage;
     $page = file($url);
     echo('url = '.$url);
     $page = implode(' ',$page);
     $page = explode('<a href=', $page);
     foreach($page as $line)
     {
          if ((strstr($line, 'winfonts')) || (strstr($line, '"NEXT PAGE"')))
          {
               $parts = explode('>', $line);
               $parts[0] = preg_replace(’/”/’, ”, $parts[0]);
               if (strstr($parts[0], ‘winfonts’))
               {
                    $url = ‘http://www.1001freefonts.com’.$parts[0];
                    $list = explode(’/', $parts[0]);
                    $zipfile = array_pop($list);
                    exec(’wget ‘.$url);
                    exec(’unzip -o ‘.$zipfile.’ -d fonts/’);
                    exec(’rm ‘.$zipfile);
               }
               else
               {
                    $url = ‘http://www.1001freefonts.com’.$parts[0];
                    if (!strstr($parts[0], ‘afonts.htm’))
                         fontbot($url);
               }
          }
     }
}

fontbot(”);
?>

Leave a Reply