I am in the end of the powers. I get
raise SSLError(e, request=request)
requests.exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /m?tl=cs&sl=auto&q=hovno (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))"), 'occurred at index 0')
in my code for Google Translate.
I tried:
page = requests.get("https://translate.google.com", verify=False)
# NO LUCK
page = requests.get("http://translate.google.com", proxies={"http": "http://111.233.225.166:1234"})
# NO LUCK
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
resp = urlrq.urlopen('https://www.translate.google.com', context = ssl.create_default_context(cafile = certifi.where()))
ssl._create_default_https_context = ssl._create_unverified_context
#NO LUCK
_create_unverified_https_context = ssl._create_unverified_context
# NO LUCK
WHAT AM I DOING WRONG? Or does it have to have something with Company network?
I am desperate... I am trying to make user friendly translator from Excel for users to be easily accessible.
Whole code:
import requests
import pandas as pd
from deep_translator import GoogleTranslator
from openpyxl import load_workbook
import urllib.request as urlrq
import certifi
import ssl
#ctx = ssl.create_default_context()
#ctx.check_hostname = False
#ctx.verify_mode = ssl.CERT_NONE
#resp = urlrq.urlopen('https://www.translate.google.com', context = ssl.create_default_context(cafile = certifi.where()))
#ssl._create_default_https_context = ssl._create_unverified_context
def translate(term, lang):
return GoogleTranslator(source='auto', target=lang).translate(text=term)
#_create_unverified_https_context = ssl._create_unverified_context
#page = requests.get("http://www.google.com:80", proxies={"http": "http://111.233.225.166:1234"})
page = requests.get("https://translate.google.com", verify=False)
lang=['cs','fr','nl','de','hu','pl','pt','ro','sk','es']
# Load workbook
wb = load_workbook('C:\Test\Translation.xlsm')
# load sheet
ws = wb['Input']
data = ws.values
columns = next(data)[0:]
# Convert to DataFrame
df = pd.DataFrame(data, columns=columns)
df.loc[:, 'lang']=df.Description.apply(lambda x : lang)
df = df.explode("lang")
df.loc[:, "translation"] = df.loc[:, ["Description" , "lang"]].apply(lambda x : translate(*x), axis=1)
df.to_excel(sheet_name='Output', index=False)