2005-08-28

Httpclient 的 Get 和 Post



使用 org.apache.commons.httpclient 的一个问题。

因为
http://www.google.com/translate_t 可以进行在线翻译。

分析 Html 代码后,使用 Apache 的 Httpclient 写了一个小程序。

使用 httpGetMethod.getResponseBodyAsString() 直接从
http://www.google.com/translate_t?hl=en&ie=UTF-8&text=test&langpair=en|zh-CN
获得页面 Html 代码后,筛选得到 test 翻译后的结果“测试”。

但是这几天突然发现 Google 返回了这样的信息:
Your client does not have permission to get URL:
/translate_t?hl=en&ie=UTF-8&text=test&langpair=en%7Czh-CN
from this server.

"&" 和 "|" 都被转码了......
弄不清楚原因......

今天突然想到,也许我不应当直接 Get ......
我应当向 http://www.google.com/translate_t
Post 上去 hl、ie、text 以及 langpair 的值......

呵呵,不知道思路对不对,等有时间验证一下......

4 comments:

Biz Oppsonline said...

Get unlimited webhosting at top web hosting

Anonymous said...

Hey, you have a great blog here! I'm definitely going to bookmark you!
I have a **WEB HOSTING** site/. It pretty much covers WEB HOSTING related stuff.
Come and check it out if you get time :-)

Anonymous said...

I came across you blog and thought you may find this site usefull. It has gas saving tips and where to find cheap gas. green day mp3 download

:)

Anonymous said...

I found your blog by accident, great info keep it up. I will be checking back often now that I know you are here!

Are you interested in small business web site hosting? If so, I have a small business web site hosting site.

Feel free to drop by and tell me what you think.