Blockland Forums > Modification Help
TCP Objects
<< < (6/7) > >>
Destiny/Zack0Wack0:

--- Quote from: Nexus on April 17, 2012, 12:09:59 AM ---You must connect to the main domain to get to the subdomains

--- End quote ---
Sub-domains usually point to different IPs if it is a distributed website (such as Google) and even if they don't, connecting to the main domain first isn't correct as Ephialtes pointed out.

--- Quote from: jes00 on April 16, 2012, 02:57:02 PM ---
--- Code: ---package Translator
{
function translate(%msg)
{
%obj = new TCPObject(TimeCheck);  

%obj.connect("translate.google.com/#auto|en|" @ strReplace(%msg, " ", "%20"));
}

function Translate::onLine(%this, %line)
{
if(%line !$= "")
{
//Do stuff
}
}

function Translate::onDisconnect(%this)
{
%this.delete();
}
};
activatePackage(Translator);

--- End code ---

--- End quote ---
1) Hashbangs and the rest of the page require JavaScript to run and even if it didn't you would need to parse the HTML to find what you want. You should be using the API.
2) The API now costs money.
jes00:

--- Quote from: Destiny/Zack0Wack0 on April 17, 2012, 03:41:41 AM ---Hashbangs and the rest of the page require JavaScript to run and even if it didn't you would need to parse the HTML to find what you want. You should be using the API.

--- End quote ---
I know this and I plan to sort through the HTML.
Destiny/Zack0Wack0:

--- Quote from: jes00 on April 17, 2012, 06:19:50 AM ---I know this and I plan to sort through the HTML.

--- End quote ---
No, you don't understand. The # value is not handled on the server-side. It is a client/browser mechanism. Try going to here and finding "yes" - it doesn't work because the TCP object is simply fetching the markup, it's not handling JavaScript and hence can not use the hashbang.
Ipquarx:

--- Quote from: Destiny/Zack0Wack0 on April 18, 2012, 01:03:39 AM ---No, you don't understand. The # value is not handled on the server-side. It is a client/browser mechanism. Try going to here and finding "yes" - it doesn't work because the TCP object is simply fetching the markup, it's not handling JavaScript and hence can not use the hashbang.
--- End quote ---
No, you don't understand.
If you have google chrome (which people should have, because internet explorer sucks) like I do, then you can track the download of files to the client browser.
If you go into google translate and translate something, two downloaded files will pop up. A file called t, and one called csi. if you look at the T file, it contains all the information for the translation, and you'd also notice that chrome tells you that it was obtained through a url GET request! And lookie lookie, the text YOU ENTERED is in that request! That means that javascript only handles parsing the output information.

Now, I tried translating "Hello! How are you doing?" into spanish, and this is the response I got:
--- Code: ---[[["¡Hola! ","Hello!","",""],["¿Cómo te va ?","How are you doing?","",""]],,"en",,[["¡Hola!",[5],1,0,585,0,3,0],["¿Cómo te va",[9],1,0,474,0,4,0],["?",[10],0,0,474,4,5,0]],[["Hello !",5,[["¡Hola!",585,1,0],["Hola",0,1,0]],[[0,6]],"Hello!"],["How are you doing",9,[["¿Cómo te va",474,1,0],["Cómo estás",0,1,0],["How are you doing",0,1,0]],[[0,17]],"How are you doing?"],["?",10,[["?",474,0,0]],[[17,18]],""]],,,[["en"]],16]

--- End code ---
All on one line.
However, notice that the translation IS in there! It just needs to be parsed out. And on top of that, the URL GET request is immensely easy to use as well!
This was the EXACT URL I used to translate the text:

--- Code: ---http://translate.google.com/translate_a/t?client=t&text=Hello!%20How%20are%20you%20doing%3F&hl=en&sl=auto&tl=es
--- End code ---
The arguments:
client=t
Don't change this. It won't work if you change that.

text=something
I'm sure you can figure it out.

hl=en
The source language. en is english.

tl=es
The target language. es is spanish. (español)

sl=auto
Just leave that. I have no idea what it does.


If you copy-paste that into your URL bar, you should get the exact same output that I got!

Just note that any spaces are replaced with %20, and any special charachters have to be URL encoded.
Destiny/Zack0Wack0:

--- Quote from: Ipquarx on April 18, 2012, 05:44:46 PM ---No, you don't understand.

--- End quote ---
Um no, I perfectly understand. What you posted had NOTHING to do with hashbangs. It's the correct method to do it - yes - but my corrections about the hashbangs were right because he was requesting the main page with a hashbang - not the private API calls you have pointed out.

And please note that there is most definitely some sort of (time) restriction on this method and although this might sound silly to say - you are practically stealing here. You should be using another API that is free. The Google Translate API is suppose to be a paid service.
Navigation
Message Index
Next page
Previous page

Go to full version