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

Generate a Google Translate API token through the Socks5 proxy using gtoken.py. #305

Closed
hongyi-zhao opened this issue Jul 26, 2021 · 4 comments
Labels

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented Jul 26, 2021

I want to use gtoken.py through a socks5 proxy. Based on the comment here and the example usage in gtoken.py, I tried with the following method, but failed:

$ pyenv shell datasci
$ pip install pysocks ipython matplotlib
(datasci) werner@X10DAi:~$ ipython
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import socks

In [2]: import socket

In [3]: socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 18889)
   ...: socket.socket = socks.socksocket

In [4]: from googletrans.gtoken import TokenAcquirer

In [5]: acquirer=TokenAcquirer()

In [6]: text = 'test'

In [7]: tk= acquirer.do(text)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-8223ccd9014e> in <module>
----> 1 tk= acquirer.do(text)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/googletrans/gtoken.py in do(self, text)
    192 
    193     def do(self, text):
--> 194         self._update()
    195         tk = self.acquire(text)
    196         return tk

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/googletrans/gtoken.py in _update(self)
     60 
     61         # this will be the same as python code after stripping out a reserved word 'var'
---> 62         code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
     63         # unescape special ascii characters such like a \x3d(=)
     64         code = code.encode().decode('unicode-escape')

AttributeError: 'NoneType' object has no attribute 'group'

Any hints for this problem will be highly appreciated.

Regards,
HY

@hongyi-zhao hongyi-zhao changed the title Use py-googletrans through a socks5 proxy. Generate a Google Translate API token through the Socks5 proxy using gtoken.py. Jul 27, 2021
@soumendrak
Copy link
Contributor

getting same issue.

@soumendrak
Copy link
Contributor

resolved after upgrading to the latest version.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Aug 24, 2021

What's you testing code snippet? I still have the following error:

(datasci) werner@X10DAi-00:~/Public/repo/github.com/ssut/py-googletrans.git$ ipython
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import socks,socket

In [2]: socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 18889)

In [3]: socket.socket = socks.socksocket

In [4]: from googletrans.gtoken import TokenAcquirer

In [5]: acquirer=TokenAcquirer()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-7a343875fe7b> in <module>
----> 1 acquirer=TokenAcquirer()

TypeError: __init__() missing 1 required positional argument: 'client'

@stale
Copy link

stale bot commented Oct 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 23, 2021
@stale stale bot closed this as completed Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants