Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

transl8it.com interface

by thealienz1 (Pilgrim)
on Aug 12, 2002 at 05:21 UTC ( #189382=sourcecode: print w/ replies, xml ) Need Help??

Category: Fun Stuff
Author/Contact Info jtarchie <thealienz123@yahoo.com> AIM: thealienz123 ICQ: 5673454
Description:

English:
--------
I was crawling the internet one day looking for translators for SMS text messaging. You so, I could be kewl, and confuse my friends with a language even I didn't understand. And so I found transl8it.com. It offers translation for english<->SMS lingo.

Lingo:
--------
I wz crawling d internet 1 dA L%kN 4 transl8rz 4 SMS txt msgN. U so, I c%d b kewl, & Confuz my fRnds w a language even I didn't undRstNd. & so I found transl8it.com. it offers transl8n 4 english<->SMS lingo.

use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::Form;

my $agent = new LWP::UserAgent;
my $url = 'http://www.transl8it.com/index.cgi?convert';
if($ARGV[0] eq '-to') {
    #Translates from english to text lingo
    print "English to lingo - \n";
    print "Type Message: ";
    my $input = <STDIN>;
    chomp($input);

    #Actual FORM post data
    my %data = (    'txtMessage' => $input,
            'direction' => '<--'
        );
    my $request = $agent->request(POST $url, [%data]);
    my $content = $request->content();
    my @forms = HTML::Form->parse($content, $url);
    foreach my $form (@forms) {
        eval{
            if(defined($form->value('txtTranslation'))) {
                print "\nTranslation: \n" . $form->value('txtTranslati
+on');
                last;
            }
        };
        if(@_) {next;}
    }
} elsif($ARGV[0] eq '-from') {
    #Translates from text lingo to english
    print "lingo to English - \n";
    print "Type Message: ";
    my $input = <STDIN>;
    chomp($input);

    #Actual FORM post data
    my %data = (    'txtMessage' => $input,
            'direction' => '-->'
        );
    my $request = $agent->request(POST $url, [%data]);
    my $content = $request->content();
    my @forms = HTML::Form->parse($content, $url);
    foreach my $form (@forms) {
        eval{
            if(defined($form->value('txtTranslation'))) {
                print "\nTranslation: \n" . $form->value('txtTranslati
+on');
                last;
            }
        };
        if(@_) {next;}
    }
} else{
    print 'perl trans.pl (-to|-from)';
}

Comment on transl8it.com interface
Download Code

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://189382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-08-21 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls