I am trying to translate Indonesian language to English using Google translate.(because I play a game that has a lot of Indonesians)
lang = id
inp = input("Enter to translate: \n").replace(" ","%20")
htmlfile = Request("https://translate.google.co.in/#" + lang + "/en/" + inp, headers = {'User-Agent': 'Mozilla/5.0'})
htmltext = urlopen(htmlfile).read().decode('utf-8')
regex = '<span id="result_box" class="short_text" lang="en">(.+?)</span>'
pattern = re.compile(regex)
trans = re.findall(pattern, htmltext)
print(trans)
when I give the input I get []
. Here is the inspect element
<span id="result_box" class="short_text" lang="en">
<span class="hps">
greeting
</span>
I need to get that "greeting" part