Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Taking Data from The INTERNET

GaL Soyer
Registered User
Join date: 24 Feb 2006
Posts: 47
04-04-2007 00:14
hello :)

smart man i SL made the BABLER that use the google translation page for SL transltion chat.

the page of google is: http://www.google.com/translate_t

now, how he did it? how can you search in the internet and get data from there?
in the google page you need to write the sentence and press button to show the translate... how can you do that???

thanks in advance! :)
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
04-04-2007 00:24
The mysteries of the internet.

It is actually quite simple.

The whole thing is a form and said form is submitted to a particular web address when you press that button. So instead of pressing that button you directly call the appropriate website/webpage with the required data.

And thou shalt be rewarded with a more or less (flawless) translation.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-04-2007 00:28
From: GaL Soyer
hello :)

smart man i SL made the BABLER that use the google translation page for SL transltion chat.

the page of google is: http://www.google.com/translate_t

now, how he did it? how can you search in the internet and get data from there?
in the google page you need to write the sentence and press button to show the translate... how can you do that???

thanks in advance! :)


I'm guessing they have just worked out the protocol / interface used by the page and are posting a request to the google translator (or an equivelent) and receiving it back it the same manner that the original page would.

EDIT : Squirrel beat me to it.
Elanthius Flagstaff
Registered User
Join date: 30 Apr 2006
Posts: 1,534
04-04-2007 01:10
From: Squirrel Wood
The mysteries of the internet.

It is actually quite simple.

The whole thing is a form


It's actually more like a series of tubes.
GaL Soyer
Registered User
Join date: 24 Feb 2006
Posts: 47
04-04-2007 07:32
well... what commands i can use? would you please direct me to WIKI page or something? i want to learn how to do it....

many thank :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-04-2007 07:35
From: GaL Soyer
well... what commands i can use? would you please direct me to WIKI page or something? i want to learn how to do it....

many thank :)


llHTTPRequest
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
04-04-2007 07:51
One of the problems you'll run into, is that llHTTPRequest will only return a limited number of characters from the http return (2048 I think). And these days, there is so much stuff in an http page or form, that the result you're trying to parse down to tends to be beyond that limit.

So things like Babler tend to also use an intermediary server, maybe running a PHP script, which can receive results > 2048, parses it down to the final answer, and then returns it to you.
Dragon Keen
Registered User
Join date: 24 Apr 2006
Posts: 245
04-04-2007 08:20
From: RJ Source
One of the problems you'll run into, is that llHTTPRequest will only return a limited number of characters from the http return (2048 I think). And these days, there is so much stuff in an http page or form, that the result you're trying to parse down to tends to be beyond that limit.

So things like Babler tend to also use an intermediary server, maybe running a PHP script, which can receive results > 2048, parses it down to the final answer, and then returns it to you.


right...

something like this would work, need to have CURL

CODE

$url = "http://URL HERE";
$data = "data=" . trim($_GET['text']); // the post form
//$data = htmlspecialchars($data);
$data = str_replace ( ' ', '%20', $data );
$data = str_replace(array("&","'"),array("%26","%27"),$data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output_data = curl_exec ($ch);
curl_close ($ch);


that will get you the returned page. You'll need to know the form variables and how to craft what your trying to translate into the form post. Then you need to get the data you really need

CODE

function get_meanlingful($head_seperator,$buffer,$foot_seperator){
// GET THE MEANLINGFUL PART
set_time_limit(120);
list($head,$meanlingful)=split("$head_seperator",$buffer,2);
list($meanlingful,$foot)=split("$foot_seperator",$meanlingful,2);

return($meanlingful);
}

$head_separator="<TEXT BEFORE THE DATA YOU NEED>";
$foot_separator="<TEXT AFTER THE DATA YOU NEED";
$truedata = get_meanlingful($head_separator,$output_data,$foot_separator);



i use the above code for a translating product, so it would work for what you need