Python goslate possible firewall probelm

185 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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',
    })