在项目当中,获得到的数据是英文,如果想翻译为中文内容,可直接调用Google接口:
当然,Google服务需要翻墙,所以要用到代理,这里代理的获取就暂且不细说(可以代理商购买)。下面主要提供java程序与配置文件参考:
TranslateUtil.java :
package com.ttz.crawl.util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import com.ttz.crawl.common.Page;
import com.ttz.crawl.config.CrawlConfig;
import com.ttz.crawl.fetch.FetchRet;
import com.ttz.crawl.fetch.HttpClientFetch;
import com.ttz.crawl.proxy.ProxyPoolMan;
/**
* 调用google 翻译接口
* @author zhaoyuchun
*/
public class TranslateUtil
{
public static Pattern