lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

Report an error when the translated content is a url link #18

Closed h1code2 closed 3 years ago

h1code2 commented 3 years ago

When I am using the code, url_suffix="com" Translated content: https://www.hkcnews.com It will pop up the following error: ` Traceback (most recent call last): File "C:\Users\xxx\Envs\xxx_venv\lib\site-packages\google_trans_new\google_trans_new.py", line 153, in translate pronounce_src = (response[0][0]) TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred: `

lushan88a commented 3 years ago
t = google_translator(url_suffix='cn',timeout=10)
text = "https://www.hkcnews.com"
text_trans = t.translate(text,lang_tgt='en',lang_src='zh')
print(text_trans)
->Https://oooooooo. and KC news.com 

I only can use url_suffix="cn", so i can't make this error =。=

lushan88a commented 3 years ago

I have fixed this problem. You can try to use the newest version. : )

h1code2 commented 3 years ago

you are awesome!