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

Error at index.js:105:17 #12

Closed
iromise opened this issue Sep 23, 2018 · 36 comments
Closed

Error at index.js:105:17 #12

iromise opened this issue Sep 23, 2018 · 36 comments

Comments

@iromise
Copy link

iromise commented Sep 23, 2018

I just input tr hello, it tells me to press command+L to show more details error

Error at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17 at <anonymous>

My nodejs version is

➜  china-google-translate-api npm --version
5.6.0
@xfslove
Copy link
Owner

xfslove commented Sep 25, 2018

@iromise thx for report, i'll take a look at this problem!

@xfslove
Copy link
Owner

xfslove commented Sep 25, 2018

@lingyv 能看一下这个异常的问题不

@lingyv
Copy link
Contributor

lingyv commented Sep 25, 2018

@iromise 这个错误是在请求 URL 时发生的, 我看不到错误信息, 你在命令行执行下面命令看看错误信息是什么:

curl https://translate.google.cn/translate_a/single?client=t&sl=auto&tl=zh-cn&hl=zh-cn&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=970599.543581

@iromise
Copy link
Author

iromise commented Sep 25, 2018

here is the result, @lingyv

➜  /tmp curl https://translate.google.cn/translate_a/single\?client\=t\&sl\=auto\&tl\=zh-cn\&hl\=zh-cn\&dt\=at\&dt\=bd\&dt\=ex\&dt\=ld\&dt\=md\&dt\=qca\&dt\=rw\&dt\=rm\&dt\=ss\&dt\=t\&ie\=UTF-8\&oe\=UTF-8\&otf\=1\&ssel\=0\&tsel\=0\&kc\=7\&q\=hello\&tk\=970599.543581

<!DOCTYPE html><html lang=en><meta charset=utf-8><meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"><title>Error 403 (Forbidden)!!1</title><style>*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}</style><a href=//www.google.com/><span id=logo aria-label=Google></span></a><p><b>403.</b> <ins>That’s an error.</ins><p>Your client does not have permission to get URL <code>/translate_a/single?client=t&amp;sl=auto&amp;tl=zh-cn&amp;hl=zh-cn&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=1&amp;ssel=0&amp;tsel=0&amp;kc=7&amp;q=hello&amp;tk=970599.543581</code> from this server.  (Client IP address: 61.148.243.12)<br><br>


  <ins>That’s all we know.</ins>

@xfslove
Copy link
Owner

xfslove commented Sep 25, 2018

@iromise can you change the domain from translate.google.cn to translate.google.com, and post the result again?

it's looks like you can not access the domain translate.google.cn

@iromise
Copy link
Author

iromise commented Sep 25, 2018

I can not access translate.google.com, but .cn is ok, here is the info

~ curl https://translate.google.com/translate_a/single\?client\=t\&sl\=auto\&tl\=zh-cn\&hl\=zh-cn\&dt\=at\&dt\=bd\&dt\=ex\&dt\=ld\&dt\=md\&dt\=qca\&dt\=rw\&dt\=rm\&dt\=ss\&dt\=t\&ie\=UTF-8\&oe\=UTF-8\&otf\=1\&ssel\=0\&tsel\=0\&kc\=7\&q\=hello\&tk\=970599.543581




^C
➜  ~ ping translate.google.cn
PING translate.google.cn (203.208.40.119): 56 data bytes
64 bytes from 203.208.40.119: icmp_seq=0 ttl=112 time=60.784 ms
64 bytes from 203.208.40.119: icmp_seq=1 ttl=112 time=50.756 ms
➜  ~ ping translate.google.com
PING www3-china.l.google.com (74.125.204.139): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

@xfslove
Copy link
Owner

xfslove commented Sep 25, 2018

@iromise ummmmm... I'm not sure why you had get message like "Your client does not have permission to get URL." . @lingyv 'll working on this.
but maybe It's not a bug, take a look at this description.

@martint028
Copy link

error information

[2018-09-25 17:44:11][ERROR: input.scriptfilter] Code 1: {
	"items": [
		{
			"title": "Error\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17\n    at process._tickCallback (internal/process/next_tick.js:68:7)",
			"subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
			"valid": false,
			"text": {
				"copy": "```\nError\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17\n```\n\n-\nGoogle Translate 1.1.0\nAlfred 3.7\ndarwin x64 18.0.0",
				"largetype": "Error\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17"
			},
			"icon": {
				"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
			}
		}
	]
}
[2018-09-25 17:44:11][input.scriptfilter] Script with argument 'kate' finished
[2018-09-25 17:44:11][ERROR: input.scriptfilter] Code 1: {
	"items": [
		{
			"title": "Error\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17\n    at process._tickCallback (internal/process/next_tick.js:68:7)",
			"subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
			"valid": false,
			"text": {
				"copy": "```\nError\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17\n```\n\n-\nGoogle Translate 1.1.0\nAlfred 3.7\ndarwin x64 18.0.0",
				"largetype": "Error\n    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17"
			},
			"icon": {
				"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
			}
		}
	]
}

@lingyv
Copy link
Contributor

lingyv commented Sep 26, 2018

@iromise i don't know why you don't have permission, maybe you can change computer or network and then run that command again.

@lingyv
Copy link
Contributor

lingyv commented Sep 26, 2018

@martint028 you got a 403 error ?

@martint028
Copy link

@lingyv yes

@sailor103
Copy link

same problem, if anyone can help me?

Error at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17 at <anonymous>

@lingyv
Copy link
Contributor

lingyv commented Sep 27, 2018

@sailor103 @martint028 if you can access translate.google.com, try this command:

curl https://translate.google.com/translate_a/single?client=t&sl=auto&tl=zh-cn&hl=zh-cn&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=970599.543581

@martint028
Copy link

@lingyv After entering this command, there is still the same error

@lingyv
Copy link
Contributor

lingyv commented Sep 27, 2018

When is the workflow installed?

@martint028
Copy link

After upgrading to the official version of Mojave

@lingyv
Copy link
Contributor

lingyv commented Sep 27, 2018

china-google-translate-api is done by modifying the code of google-translate-api
.
can you follow the README.md of google-translate-api
and try it ?

@xfslove
Copy link
Owner

xfslove commented Sep 29, 2018

related issue

@Astraeux
Copy link

我也遇到了这个问题,curl translate.google.com 或 translate.google.cn 都产生相同错误

@piccy
Copy link

piccy commented Sep 30, 2018

Maybe the problem is missing User Agent:

curl -A "Mozilla/5.0" "https://translate.google.cn/translate_a/single?client=t&sl=auto&tl=zh-cn&hl=zh-cn&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=970599.543581"

Return is OK.

curl "https://translate.google.cn/translate_a/single?client=t&sl=auto&tl=zh-cn&hl=zh-cn&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=970599.543581"

Return is 403.

@xfslove
Copy link
Owner

xfslove commented Sep 30, 2018

@sailor103 @martint028 @iromise @Astraeux Please have a try.

@Astraeux
Copy link

Astraeux commented Sep 30, 2018

@sailor103 @martint028 @iromise @Astraeux Please have a try.

curl with User Agent is OK. But how to solve this error?

@piccy
Copy link

piccy commented Sep 30, 2018

@xfslove
@Astraeux

vi /usr/local/Cellar/node@6/6.13.0/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js

chage line 52 to :

        return got(url, {headers: { 'user-agent': 'Mozilla/5.0' }}).then(function (res) {

@xfslove
Copy link
Owner

xfslove commented Sep 30, 2018

if it's works, @lingyv 'll update translate-api packages.

@lingyv
Copy link
Contributor

lingyv commented Sep 30, 2018

ok, i get it, thank you all.
I have upgraded the version from 2.3.0 to 2.3.1.

@Astraeux
Copy link

@xfslove
@Astraeux

vi /usr/local/Cellar/node@6/6.13.0/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js

chage line 105 to :

        return got(url, {headers: { 'user-agent': 'Mozilla/5.0' }}).then(function (res) {

line 105:

            e = new Error();

line 52:

        return got(url).then(function (res) {

I try change line 52 to:

        return got(url, {headers: { 'user-agent': 'Mozilla/5.0' }}).then(function (res) {

But it does't work.

Error
    at /usr/local/lib/node_modules/alfred-google-translate/node_modules/china-google-translate-api/index.js:105:17
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
```

-
Google Translate 1.1.0
Alfred 3.7
darwin x64 17.5.0`

@likecreep
Copy link

likecreep commented Oct 2, 2018

亲测是china-google-translate-token 这个依赖产生的tk没有作用了。 测试产生的tk是914092.914092。然后 curl -A "Mozilla/5.0" "https://translate.google.cn/translate_a/single?client=t&sl=auto&tl=zh-cn&hl=zh-cn&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=hello&tk=914092.914092" 得到的response是403

@PangciPG
Copy link

PangciPG commented Oct 7, 2018

这个问题解决了吗??

@xfslove
Copy link
Owner

xfslove commented Oct 8, 2018

这个问题解决了吗??

这个问题目前看来应该是api限制的原因,目前还没有好的办法解决

@Astraeux
Copy link

Astraeux commented Oct 8, 2018

这个问题解决了吗??

这个问题目前看来应该是api限制的原因,目前还没有好的办法解决

为什么我执行curl加上user agent可以成功,但代码加上user agent仍然失败?

@xfslove
Copy link
Owner

xfslove commented Oct 8, 2018

@likecreep 说的可能生成的token没用

@lingyv
Copy link
Contributor

lingyv commented Oct 15, 2018

不能用的小伙伴, 可以先用有道翻译

@lingyv
Copy link
Contributor

lingyv commented Oct 15, 2018

look at this issues, and try this way

@Astraeux
Copy link

look at this issues, and try this way

This way is worked, don't need to change user agent.

@lingyv
Copy link
Contributor

lingyv commented Oct 15, 2018

ok, thank you, i'll upgrade later

@lingyv
Copy link
Contributor

lingyv commented Oct 15, 2018

everybody, i have pushed the update, please upgrade your workflow and try again.

@xfslove xfslove closed this as completed Oct 15, 2018
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

9 participants