Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

MSXML 6 with Google Translate

Hi everyone!

I trying to write a app to do some chinese->english translation using google. I have all the code down to generate the right URL, i.e.

http://translate.google.com/translate_t?text=%E4%BD%A0%E5%A5%BD&hl=en&langpair=zh-CN|en&tbb=1&ie=utf-8

I can paste that into a browser and it works, but when I try to request the page using msxml 6.0 I get a 403 error (forbidden). I tried requesting "www.google.com" first, thinking maybe I need a cookie, and google.com returns fine, but still when I go on to the translate url I get the 403. Is there anyway around this, maybe changing my request header?

Thanks
-Josh K
[663 byte] By [JoshK] at [2007-11-11 9:52:06]
# 1 Re: MSXML 6 with Google Translate
You might try using a tool like Fiddler or ieHTTPHeaders to see exactly what gets sent to Google when you request the translation page in the browser.
Phil Weber at 2007-11-11 21:45:17 >
# 2 Re: MSXML 6 with Google Translate
Thanks for the suggestion. I tried fiddler, but I didn't really understand what I was seeing or how to change the request header in msxml, so I just ditched msxml all together and tried using the vb.net WebBrowser control.

I had a little more success using it; the page gets returned with no 403, but, well hard to explain unless you look at this page:

http://translate.google.com/translate_t?text=%E4%BD%A0%E5%A5%BD&hl=en&langpair=zh-CN%7Cen&tbb=1&ie=utf-8

so if you put that in your browser, you see ?? (or chinese characters if you have the language pack installed) in the 'Original Text:' box, and "Hello" as the translation. However, when I use this same URL in the webbrowser control of vb.net the returned page has ?? as the 'Original Text:' and "-" as the translated text.

Now this is really making me go bonkers. Anyone tell me what the **** is going on? I will bow down if you help me through this
JoshK at 2007-11-11 21:46:17 >