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:
(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