Create Your First BOT
This will be a very, very basic tutorial on what a bot is and how to create one. First you need to understand that a "BOT" is only a series of programming commands/functions that do "SOMETHING".
In this example my bot will: GRAB ALL USERNAMES FROM ALL-NETTOOLS.COM
First we need to find out how all-nettools.com displays usernames so first we need to click on "[url=http://www.all-nettools.com/forum/memberlist.php]Member List[/url]".
Notice the URL structure of each user profile: [url]http://www.all-nettools.com/forum/member.php?u=657*[/url]
With a little digging you will find that the first user (OTTO - administrator) is
[url]http://www.all-nettools.com/forum/member.php?u=*[/url]
We can now get started writing our bot. You need to make a step by step list of what you want the bot to do.
*. Check to see if URL exists
2. Grab HTML from URL
*. Find username starting point in html
4. Find username ending point in html
5. Grab next URL
PHP CODE
Code:
function bot_allnettools($user){
// CHECK TO SEE IF URL EXISTS
if($current_webpage=file_get_contents("http://www.all-nettools.com/forum/member.php?u=" . $user)){
$user_identifier_beginning="<div class=\"bigusername\">";
$user_identifier_end="<img";
// CHECKS FOR MATCHING PATTERN WITH BEGINNING AND ENDING IDENTIFIERS (NOTICE THE WILDCARD IN THE MIDDLE)
if (preg_match('/' . $user_identifier_beginning . '(.*?)' . $user_identifier_end . '/',$current_webpage,$match)) {
$match[0]=str_replace($user_identifier_beginning,"",$match[0]);
$match[0]=str_replace($user_identifier_end,"",$match[0]);
return($match[0]);
}
}
return(0);
}
I am not posting my live example because it uses a lot of the bandwidth allocated to all-nettools.com. This was only an example so please do not use this information to create bots on all-nettools.com or you will be permanently banned and reported to your ISP.
~SyntaX