goslate从西班牙语转换为英语http错误

时间:2017-09-15 15:40:51

标签: python http goslate

我正在尝试使用以下代码将2个大文档从西班牙语翻译成英语:     导入goslate

big_files = ['lenin.txt', 'liga.txt']
gs = goslate.Goslate()

translation = []
for big_file in big_files:
    with open(big_file, 'r') as f:
        translated_lines = []
        for line in f:
            translated_line = gs.translate(line, "en")
            translated_lines.append(translated_line)

        translation.append('\n'.join(translated_lines))

我收到此错误:

  

文件“C:\ Anaconda \ lib \ urllib \ request.py”,第590行,在http_error_default中引发HTTPError(req.full_url,code,msg,hdrs,fp)

     

HTTPError:服务不可用

1 个答案:

答案 0 :(得分:2)

通过Python访问Web内容时尝试的一般适用的方法是通过浏览器访问Web内容,以查看问题是在Python还是其他地方,例如您的Internet连接。另一个更普遍适用的策略是谷歌无论遇到什么问题。 “goslate”的第一个Google结果返回:

  

Google最近使用故障单机制更新了其翻译服务,以防止像goslate这样的简单抓取程序访问。

https://pypi.python.org/pypi/goslate

我认为这解释了你的问题。