Coder Social home page Coder Social logo

google-translate's Introduction

文件目录说明

core目录内是google翻译的核心代码

rpc_server内的server.py是rpc的服务端,在其中调用core目录内的代码

rpc_conf.py是rpc的配置代码

rpc_client.py是rpc客户端的测试代码,可参考其中代码自实现该代码

运行

  • 1.运行rpc_server内的server.py启动rpc服务
  • 2.运行rpc_client.py进行测试rpc服务是否运行正常

调用rpc翻译服务需要传递的参数说明

需要传递一个字典,具体可见rpc_client.py中代码,该处对字典进行说明:

translate_word = {'src': 'zh-CN', 'dest': 'en', 'content': content, 'cookies': cookies}
# content 要翻译的内容
# cookies google返回的cookies
# src 原文语言
# dest 目标语言
# 常用语言说明  中文 zh-CN,英文:en,日文:ja,韩文:ko

一些问题

  • google翻译支持5000字符的翻译量(实测没有这么多)
  • 翻译过程中可能会出现反爬导致异常,捕获异常跳过本次翻译仍可继续运行
  • google的cookies时间较长,一般情况下无需多次获取该值
  • google响应结果中可能会出现</ em>标签, 注意处理

google-translate's People

Contributors

hy89 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.