Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why now I have to use -p to add a proxy? Is this due to Google ? 为什么现在需要代理才能用 是谷歌的原因吗 #43

Open
jinastro opened this issue Sep 29, 2022 · 16 comments

Comments

@jinastro
Copy link

jinastro commented Sep 29, 2022

Although there is a similar issue, but I think it is better to demonstrate my issue which might be a little bit different.
虽然有个差不多的问题 但是我还是说一下我的问题 可能不太一样

recently, the command can not work
最近 这个命令不能用了 前几天还能用

python3 -m googletranslate zh-CN word

there are the errors
错误长这样

Errrrrrrrrror: HTTPSConnectionPool(host='translate.googleapis.com', port=443): Max retries exceeded with url: /translate_a/single?client=gtx&sl=auto&tl=zh-CN&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=sos&dt=ss&dt=t&ssel=0&tsel=0&kc=1&tk=547524.975478&q=test (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fd47b9ea2f0>, 'Connection to translate.googleapis.com timed out. (connect timeout=5)'))

And adding -p proxy could solve a part of the issue
加代理就行了

python3 -m googletranslate -p 127.0.0.1:8118 zh-CN word

But comparing to before, it is a littile slow and sometimes it has the proxy error, like this
但是貌似比之前慢一些 有时侯也会报代理错误 然后翻译不了

(╯‵□′)╯︵┻━┻: ProxyError...

So, what is the problem. Is it because of google or this python module?
所以 是这个模块的问题 还是 google 的问题

@Ethkuil
Copy link

Ethkuil commented Oct 1, 2022

检验方法:关掉代理,用浏览器打开Google翻译。

我试了下,发现.com和.cn都无法访问,但.hk可以。

@JohanChane
Copy link

检验方法:关掉代理,用浏览器打开Google翻译。

我试了下,发现.com和.cn都无法访问,但.hk可以。

https://linux.cn/article-15094-1.html

@Ethkuil
Copy link

Ethkuil commented Oct 1, 2022

检验方法:关掉代理,用浏览器打开Google翻译。
我试了下,发现.com和.cn都无法访问,但.hk可以。

https://linux.cn/article-15094-1.html

谢谢。真是可惜,哎。

但我今天用的时候也确实觉得有时响应时间过分偏长了,不知道为什么。不是很稳定。但其他需要翻墙的地方都还流畅的……

话说也许额外支持一些国产的翻译网站可能也不错。

@jinastro
Copy link
Author

jinastro commented Oct 2, 2022

检验方法:关掉代理,用浏览器打开Google翻译。

我试了下,发现.com和.cn都无法访问,但.hk可以。

https://linux.cn/article-15094-1.html

原来如此 那没啥好办法了 哭了😭😭😭

@ChihSee-Hsie
Copy link

这样的话,脚本应当怎么改呢?😭️

@Ethkuil
Copy link

Ethkuil commented Oct 8, 2022

这样的话,脚本应当怎么改呢?😭️

@ChihSee-Hsie 用能翻墙的代理,访问 .com。在指令行的末尾添上-p <proxy>,比如我的是-p 127.0.0.1:10802(这个地址具体要看你自己的情况)。

然后在 GoldenDict 里用就形如python -m googletranslate zh-CN %GDWORD% -p 127.0.0.1:10802,这个就是翻译成简中的命令行。

@ChihSee-Hsie
Copy link

这样的话,脚本应当怎么改呢?😭️

@ChihSee-Hsie 用能翻墙的代理,访问 .com。在指令行的末尾添上-p <proxy>,比如我的是-p 127.0.0.1:10802(这个地址具体要看你自己的情况)。

然后在 GoldenDict 里用就形如python -m googletranslate zh-CN %GDWORD% -p 127.0.0.1:10802,这个就是翻译成简中的命令行。

感谢思路。我试着将脚本使用的网址 translate.googleapis.com 添加到强制使用代理的列表中,也能达到效果。

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

这样的话,脚本应当怎么改呢?😭️

@ChihSee-Hsie 用能翻墙的代理,访问 .com。在指令行的末尾添上-p <proxy>,比如我的是-p 127.0.0.1:10802(这个地址具体要看你自己的情况)。

然后在 GoldenDict 里用就形如python -m googletranslate zh-CN %GDWORD% -p 127.0.0.1:10802,这个就是翻译成简中的命令行。

我代理用的是clash 还是会提示错误. Expecting value: line 1 column 1 (char 0)
你是什么平台 用的什么代理 ?

@Ethkuil
Copy link

Ethkuil commented Oct 11, 2022

@vipzrx WinXray, iGuge. 可能都是比较小众的选择?

不过你能确定是代理本身的问题吗?比如说在命令行里能用吗?可能是其他地方弄错了也说不定。只要浏览器里能翻墙,GoldenDict 里应该就也没问题。

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

1 在命令行里面也是报这个错误

2 我就是安装了python

pip安装了插件

pip3 install google-translate-for-goldendict

命令行 中
C:\Users\kk\AppData\Local\Programs\Python\Python39\python.exe -m googletranslate -p 127.0.0.1:1080 zh-CN %GDWORD% -s "translate.google.cn"


C:\Users\kk>C:\Users\kk\AppData\Local\Programs\Python\Python39\python.exe -m googletranslate  -p 127.0.0.1:1080 zh-CN %GDWORD% -s "translate.google.cn"
Errrrrrrrrror: Expecting value: line 1 column 1 (char 0)

我用 Errrrrrrrrror: Expecting value: line 1 column 1 (char 0) 搜这个仓库 有4个issue (https://github.com/xinebf/google-translate-for-goldendict/search?q=Errrrrrrrrror%3A+Expecting+value%3A+line+1+column+1+%28char+0%29&type=issues)
也没看明白是怎么回事.好像是和代理有关. 我这边用clash for windows,网页版本 谷歌翻译 能正常访问. 作者也说修复了

这个错误,再谷歌中,也没有收到有用信息

@Ethkuil
Copy link

Ethkuil commented Oct 11, 2022

谷歌翻译的 .cn 站点已经关了,见评论区上方。改.com试试。

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

谷歌翻译的 .cn 站点已经关了,见评论区上方。改.com试试。

换成com 可以用了

命令行中 显示


C:\Users\kk>C:\soft\soft_install\msys64\mingw64\bin\python.exe -m google-translate-for-goldendict-academic  -p 127.0.0.1:1080 zh-CN %GDWORD% -s "translate.google.com"
<html>
<head>
        <style type="text/css">
        p {white-space: pre-wrap;}
        pos {color: #0000FF;}
        example {color: #008080;}
        gray {color: #606060;}
        </style>
</head>
<body>
<p>%GDWORD%
</p>
</body>
</html>

doldendict 中显示 正常
image

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

再请教一个问题

pypi中是1.3.9 发布日期是 2021 年 12 月 26 日
https://pypi.org/project/google-translate-for-goldendict/

github上最新的更新是 2022 1月15日 有1个提交

我怎么使用作者最新的github上的源码?

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

谷歌翻译的 .cn 站点已经关了,见评论区上方。改.com试试。

我使用作者github上的源码, cmd中报错如下

C:\Users\kk>C:\soft\soft_install\msys64\mingw64\bin\python.exe C:\soft\soft_x200\xinebf..google-translate-for-goldendict\googletranslate\googletranslate.py -p 127.0.0.1:1080 zh-CN %GDWORD% -s "translate.google.com"

Traceback (most recent call last):
File "C:\soft\soft_x200\xinebf..google-translate-for-goldendict\googletranslate\googletranslate.py", line 20, in
from .googletranslatetk import Token
ImportError: attempted relative import with no known parent package

我想要使用作者最新的源码,命令行是这样写吗? 正确的该怎么写呢?

@vipzrx
Copy link

vipzrx commented Oct 11, 2022

@Ethkuil

https://pypi.org/project/google-translate-for-goldendict-academic/
pypi.com上有个新的库

从你的源码修改的,功能如下

Modified from google-translate-for-goldendict (xinebf):

remove emoji;

remove line break in PDF when using “Scan Popup”.

我不熟悉,python.没有找到他的源码,也没有找到他这个修改版本的使用方法. 你有兴趣看下他的源码吗? 他提到的两个增强,有必要合并到你的代码吗?

@Ethkuil
Copy link

Ethkuil commented Oct 11, 2022

  1. 这个库其实不是我维护的,我甚至没读过源码orz
  2. 它做了2个变动,1个是删掉提示信息的emoji,这个我觉得无所谓;另一个是优化了PDF里的断行,这个我试了下,现在的这个确实会有问题,会因为检测到EOF而出错,不过对我来说这个改进无所谓(我会先OCR一下再复制)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants