0

I'm trying to use goslate to translate some excel files. When I try to run the following code I get this error:

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

import goslate

gs = goslate.Goslate()
new_word = gs.translate('Hallo mein Freund', 'de')
print(new_word)

I'm pretty sure this is caused by some problem in my IT department, like port blocking. Is there anyway to more specifically determine what the problem is?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Trubsworth
  • 45
  • 6
  • `goslate` seems to be **outdated**. Read [Service Unavailable goslate](https://stackoverflow.com/a/35610872/7414759) – stovfl Feb 05 '19 at 13:43
  • @stovfl Hmm.... it seems there may not be a solution to my problem since google made the translate API a paid service. Any other suggestions for translation? – Trubsworth Feb 05 '19 at 15:44

1 Answers1

0

I believe you were sending too many requests and your ISP is blocking the request (hence it refused the connection). You could either have a new DHCP IP address, and get it to work again. Or you could modify the headers variable with the requests library used in goslate:

# Google forbits urllib2 User-Agent: Python-urllib/2.7
request = Request(url, headers={'User-Agent':'Mozilla/4.0'})

To:

request = Request(url, headers={
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
    })
Sam Al-Ghammari
  • 1,021
  • 7
  • 23