synonym not slugified was causing error

This commit is contained in:
Gourav Kumar 2022-01-10 07:10:38 +05:30
parent b77f85e2da
commit 5260e4fbf5

View File

@ -137,7 +137,7 @@ def get_synonyms(word: str) -> str:
response = requests.get(syn_url.format(word.lower())) response = requests.get(syn_url.format(word.lower()))
soup = BeautifulSoup(response.content, 'html.parser') soup = BeautifulSoup(response.content, 'html.parser')
synonyms = soup.find_all(['strong', 'span'], {'class': 'syn'}) synonyms = soup.find_all(['strong', 'span'], {'class': 'syn'})
synonym_list = [f'\n*{slugify(i.string)}*' if i.name == 'strong' else i.string for i in synonyms] synonym_list = [f'\n*{slugify(i.string)}*' if i.name == 'strong' else slugify(i.string) for i in synonyms]
return (''.join(synonym_list)) return (''.join(synonym_list))