Dec 27 2009

Mini Bots PHP Class

Giulio Pons @ 11:49 pm

LAST UPDATE 01/11/2011 This php class is a growing collection of small spiders that go out on the web and make some small usefull works. I’ve decided to raise it to the top level menu beacuse I think it’s a nice project, and I will explain the functions in the blog.

Since this class could violate the rules of other sites, please, use this class properly, be correct: I mean, bots can cause problems to server, and can be used to steal contents, so use those scripts with attention (that is to say “not too much”). This class was build for educational purpose, so check the rules of the called services to decide if you can use those scripts in your commercial products, I don’t know.

Actually the mini bots can do those things:

Version 1.9f includes:

  1. check if a remote mp3 exists and is an mp3
  2. search Myspace Concerts (DEMO)
  3. search Google and get the spelling suggest (DEMO)
  4. search Google and retrieve the meteo information for a place
  5. search Bank Of Italy service to get exchange rates for a specified currency
  6. search GeoIpTool to retrieve geographical information from a specified IP address (DEMO)
  7. contact any mail server to validate email address through smtp protocol (DEMO)
  8. call tinyurl.com to get a tiny url of a specified long url (DEMO)
  9. decode any small url to the original long url (DEMO)
  10. url checker to see if a url exists
  11. get url infos to get data about a page (title, description, favicon, images) (DEMO)
  12. retrieves all the text from a url
  13. convert a url to a pdf and save it to a local file
  14. get twitter users info from web page and from Twitter’s API
  15. set twitter status
  16. get twitter statuses update list
  17. get video list uploaded by a user in Youtube (DEMO)
  18. get first page of url images from Google Images (DEMO)
  19. change facebook status
  20. post to facebook fan page wall
  21. parsing rss flickr feed of a user (DEMO)
  22. sending push alerts to iPhone (DEMO)
  23. google suggest keywords service (DEMO)
  24. find definitions on Wikipedia (DEMO)
  25. convert a street address to latitude/longitude coordinates (DEMO)

DOWNLOAD:

Here is the DOWNLOAD PHP source and the DEMO INDEX.

HISTORY:
ver.1.9g, added check if an mp3 exists and is an mp3, minor updates
ver.1.9e, fixed myspace
ver.1.9d, myspace, latitude longitude and more
ver.1.9, wikipedia definitions
ver.1.8, pushMeTo, google suggest
ver.1.7, various fixes and Flickr Feed parser
ver.1.6a, post to facebook fan page wall
ver.1.6, add twitterInfoApi (like twitterInfo but faster), add twitterSetStatus, add twitterGetStatusList, add youtubeGetVideos, googleGetImages
ver.1.5, modified twitterInfo, fixed private functions, addedd facebook status method.
ver.1.4, added twitterInfo, wepage2txt and url2pdf methods.
ver.1.3, added url_exists and getUrlInfo methods.

Share

43 Responses to “Mini Bots PHP Class”

  1. seeal says:

    love this class thx :D

  2. Matteo says:

    Great class , thanks :)

  3. Greg Avola says:

    Great work dude – way to go.

  4. uberVU - social comments says:

    Social comments and analytics for this post…

    This post was mentioned on Twitter by deliciobot: #DelicioBot : Mini Bots PHP Class http://bit.ly/5sfw5Q...

  5. holyguard says:

    Utilissimo!!!

    Puoi usare l’exchange rate di Google invece di quello della banca d’Italia, che te ne pare?

  6. Tod Wedge says:

    Just landed on this place via Google seek. I love it. This post change my percept and I am taking the RSS feeds. Cheers Up.

  7. webcarlo says:

    complimenti però sappiate che Google non gradisce che si facciano query nei suoi servizi che non prevedono API, potrebbe penalizzare un sito che serve i dati con il grabbing

  8. admin says:

    Credo che l’importante sia non abusarne, anche Google fa grabbing a tutti i livelli, non sono sicuro che penalizzi queste attività, dove l’hai letto?

  9. PHP Mini bot « My Blog says:

    [...] there are 17 bots included in this class! Well I’ve updated the mini bots class with some new things: you can now retrive the list of videos from a Youtube user, you can retrieve [...]

  10. LongVNIT » Ping pingomatic.com services with PHP says:

    [...] The complex part, for me, was understing XML-RPC rules and build the correct headers to call the service. The call is made with fsockopen php function. Here is the function that will be added to the next version of Mini Bot Class. [...]

  11. Jorge Garifuna says:

    I just tried updating my twitter status with the mini bot’s twitterSetStatus() function and the functioned returned false which indicates that my status was not updated. I verified on twitter and no update was set to my status.

    Does this have anything to do with the oAuth implementation of twitter?

    Any ideas to get twitter update status to work in the near future?

  12. Giulio Pons says:

    Yes. Since 31, 2010 twitter made basic autenthication deprecated, I will soon make available a different version of the function (I hope).

  13. Jorge Garifuna says:

    Thanks a million. I’m currently using the facebook status update and it works great!

  14. Jorge Garifuna says:

    Any ideas to add hi5.com to this class?

  15. Facebook Status Updates mit PHP - c0de says:

    [...] hab auf barattalo.it diese wirklich geniale Funktion entdeckt die er als teil einer Bot Classe [...]

  16. Mini Bot Class Updated - Barattalo says:

    [...] Mini Bots PHP Class [...]

  17. Ronan says:

    Bel lavoro davvero !

    peccato che tu non abbia scelto una licence per questo script.
    The Free Software Foundation has recommended that the GNU AGPLv3 be considered for any software that will commonly be run over a network

    Saluti dalla Bretagna,
    Ronan

  18. Giulio Pons says:

    Ciao Ronan, non conosco bene le licenze, mi leggerò quella che mi consigli. Ciao!

  19. Douglas Ianitsky says:

    Hey, Thanks for class.

    I modify the googleGetImages function for get a especify quanty.

    public function googleGetImages($k, $quant = 20) {
    		$x = array();
    		$next = 0;
    		while ($next < $quant) {
    			$url = "http://www.google.com.br/images?q=##query##&gbv=2&sout=1&tbs=isch:1,itp:##query##&sa=N&start=##next##&ndsp=20";
    			$web_page = file_get_contents( str_replace(array("##query##", "##next##"), array(urlencode($k), $next), $url ));
    			$tieni = stristr($web_page,"dyn.setResults(");
    			$tieni = str_replace( "dyn.setResults(","", str_replace(stristr($tieni,");"),"",$tieni) );
    			$tieni = str_replace("[]","",$tieni);
    			$m = preg_split("/[\[\]]/",$tieni);
    
    			for($i=0;$i<count($m);$i++) {
    				$m[$i] = str_replace("/imgres?imgurl\\x3d","",$m[$i]);
    				$m[$i] = str_replace(stristr($m[$i],"\\x26imgrefurl"),"",$m[$i]);
    				$m[$i] = preg_replace("/^\"/i","",$m[$i]);
    				$m[$i] = preg_replace("/^,/i","",$m[$i]);
    				if ($m[$i]!="") {
    					array_push($x,$m[$i]);
    					if (++$next >= $quant)
    						break;
    				}
    			}
    		}
    		return $x;
    	}
    
  20. Douglas Ianitsky says:

    Another small change

    // get list of images from google images
    //$k == query to search
    //$quant == total of itens that you need
    //$check == check if image link is broken (depending on the amount of images, the time to check them becomes too long. Use only if absolutely necessary.)
    public function googleGetImages($k, $quant = 20, $check = false) {
    	$x = array();
    	$next = 0;
    	while ($next < $quant) {
    		$url = "http://www.google.com/images?q=##query##&gbv=2&sout=1&tbs=isch:1&sa=N&start=##next##&ndsp=20";
    		$web_page = file_get_contents( str_replace(array("##query##", "##next##"), array(urlencode($k), $next), $url ));
    		$tieni = stristr($web_page,"dyn.setResults(");
    		$tieni = str_replace( "dyn.setResults(","", str_replace(stristr($tieni,");"),"",$tieni) );
    		$tieni = str_replace("[]","",$tieni);
    		$m = preg_split("/[\[\]]/",$tieni);
    
    		for($i=0;$i<count($m);$i++) {
    			$m[$i] = str_replace("/imgres?imgurl\\x3d","",$m[$i]);
    			$m[$i] = str_replace(stristr($m[$i],"\\x26imgrefurl"),"",$m[$i]);
    			$m[$i] = preg_replace("/^\"/i","",$m[$i]);
    			$m[$i] = preg_replace("/^,/i","",$m[$i]);
    			if ($m[$i]!="") {
    				if ($check) {
    					if (@getimagesize($m[$i])) {
    						array_push($x,$m[$i]);
    						if (++$next >= $quant)
    							break;
    					}
    				} else {
    					array_push($x,$m[$i]);
    					if (++$next >= $quant)
    						break;
    				}
    			}
    		}
    	}
    	return $x;
    }
    
  21. Giulio Pons says:

    Thank you Douglas!

  22. Michael says:

    Wow really amazing, very usefull collection! Thanks!!

  23. nina says:

    can you make function for parse facebook wall feeds ?

  24. santiago says:

    Thanks!!

  25. Putranto says:

    Just what i needed, twitter status change without messy oAuth !!! Thanks bro, excellent !!!

  26. Php – Script to ping pingomatic.com | Linux tutorials says:

    [...] The complex part, for me, was understing XML-RPC rules and build the correct headers to call the service. The call is made withfsockopen php function. Here is the function that will be added to the next version of Mini Bot Class. [...]

  27. Stefano says:

    Sto provando il codice di Douglas per recuperare l’immagine da Google Images, ma ottengo sempre un errore di sintassi T_PUBLIC. Ho tolto il public alla funzione e non restituisce più l’errore ma non ritorna niente, pagina bianca (test effettuato tramite XAMPP).

    prima della classe ho semplicemente inserito una riga così:
    $k = “MC544FD/A”;
    Dopodichè ho modificato quantità in 1 ed abilitato il check dell’esistenza dell’immagine.

    Devo inserire altro codice per visualizzare l’immagine?

    Inoltre è possibile inserire un controllo “di pertinenza”? Mi spiego, se il primo risultato ha un nome estremamente diverso da quello cercato (e lo chiedo perchè io sto cercando dei codici di prodotto) è possibile dire allo script di skippare il grab dell’immagine?

    Grazie mille!

  28. Joseph says:

    I will use this class in my collection of web directories and submission form. Thanks.
    Directory Gist – Directory of Web Directories –
    http://www.directorygist.com
    ———–
    Searcheable database of 7000 free web directories, Search Engines, social BookMarking Sites, Article Directories. Also online submission tools to ease your website promotion.

  29. SAYIM says:

    Great class.
    However, I need the page URL as well in the result.
    For example, I need http://www.example.com/the_page.php as well as http://www.example.com/the_page/imageX.jpg

    Thanks,

  30. Short Links says:

    Great class. Please could you add the short URL service at http://101.gs to “decode any small url to the original long url”

    Thanks

  31. Hung Nguyen says:

    So great,
    Your Bot class so useful.
    Thanks

  32. Derrick Duriga says:

    Greetings! I know this is somewhat off topic but I was wondering which blog platform are you using for this site? I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform. I would be great if you could point me in the direction of a good platform.

Leave a Reply