I'm trying to scrape some German sentences from Glosbe.com. The requested URL contains some utf-8 characters. The website doesn't change the quoted characters to utf-8 characters after the request is done. The requested URl should look like this
https://glosbe.com/de/hu/abkühlen
But the requested URL from the website is not converted to utf-8 and the searched word is this
https://glosbe.com/de/hu/abk%C3%BChlen/
The used code:
def beautifulSoapPrepare(sourceLang,destLang,phrase):
headers = {
'User-Agent': 'My User Agent 1.0',
'From': 'youremail@domain.example' # This is another valid field
}
url="https://glosbe.com/"+sourceLang+"/"+destLang+"/"+urllib.parse.quote(phrase)+"/"
r = requests.get(url, "lxml",headers=headers)
soup = BeautifulSoup(r.content,features="lxml")
return soup
The picture here shows the problem. The problem in picture
Could you please help me solve this issue? I want the website to search for the German word abkühlen and not this abk%C3%BChlen.
Solution: The Problem was in the URL. Once I deleted the slash at the end of the URL it worked.
Before:
url="https://glosbe.com/"+sourceLang+"/"+destLang+"/"+urllib.parse.quote(phrase)+"/"
After:
url="https://glosbe.com/"+sourceLang+"/"+destLang+"/"+urllib.parse.quote(phrase)