2

I have installed textblob and I want to perform simple translation.

>>> text="Hello"
>>> blob=TextBlob(text)
>>> blob.translate(to="es")

The problem is, I dont know where to specify the proxy authentication. Can you tell me where to specify the username, password and proxy address so that I can get it working?

Sean
  • 60,939
  • 11
  • 97
  • 136
codingsplash
  • 4,785
  • 12
  • 51
  • 90

1 Answers1

2

I applied this trick in my code and it is working fine.

1) Import the "nltk" library.

2) Insert this line in your code, replace the username, password, proxy and port to your needs:

nltk.set_proxy('http://username:password@proxy:port')

Now your code would look like this:

import textblob

import  nltk
from textblob import TextBlob
text="Hello"
blob=TextBlob(text)
nltk.set_proxy('http://username:password@proxy:port') 
blob.translate(to="es")
print(blob.translate(to="es"))
Martin Zabel
  • 3,589
  • 3
  • 19
  • 34
Rahul Kant
  • 137
  • 1
  • 1
  • 9
  • Did it work ? I tried this code for no avail. I get this error : urllib.error.HTTPError: HTTP Error 403: URLBlocked-category_restriction – grshankar Aug 08 '18 at 12:52
  • its working for me as well! sometimes the world is crazily easy! – PV8 Jun 11 '19 at 13:23