I want to know if a word is in the dictionary.
Here is what I am trying.
import requests
def word_in_dictionary(word):
response = requests.get('https://en.wiktionary.org/wiki/'+word)
return response.status_code==200
print(word_in_dictionary('potato')) # True
print(word_in_dictionary('nobblebog')) # False
But unfortunately the dictionary contains a lot of words that are not English and I don't want to match those.
print(word_in_dictionary('bardzo')) # WANT THIS TO BE FALSE
So I tried to look in the content.
def word_in_dictionary(word):
response = requests.get('https://en.wiktionary.org/wiki/'+word)
return response.status_code==200 and 'English' in response.content.decode()
But I am still getting True. It is finding "English" somewhere in the page source even though the rendered page doesn't have it (nothing when I search with ctrl-F in the browser).
How can I make it only return True if it is actually listed as having a meaning in English?
` tag?
– Jiří Baum Aug 28 '20 at 11:10