I have encountered an unexpected situation.
I'm scraping words from the website SpanishDict.com.
For example:
I search for the term niño, then .py gives me below result which exactly I wanted.
(nee-nyoh)
masculine or feminine noun
But when I search que, then .py gives me a totally wrong result as below;
(kweh-behk)
conjunction
According to definition of que, .py should've give me a result like below;
(keh)
conjunction
So I'm wondering what's wrong with this? Any idea?
Thanks
I have included my code below:
import requests
from bs4 import BeautifulSoup
base_url = "https://www.spanishdict.com/translate/"
search_keyword = input("input the keyword : ")
url = base_url + search_keyword
spanishdict_r = requests.get(url)
spanishdict_soup = BeautifulSoup(spanishdict_r.text, 'html.parser')
# Phonetic Alphabet
print(spanishdict_soup.find('span', {'class': 'dictionaryLink--369db'}).text)
# Part of Speech
print(spanishdict_soup.find('a', {'class': 'href--2RDqa'}).text)
# Meaning
Just replace your first search criterion with:
spanishdict_soup.find("span", {"id": "dictionary-link-es"}).text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With