spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

commit f8753a69553fdb7e162dba5f522ffda0c5a112cd
parent 8e9344e37d0bcf97f553b22e7b5a4a0727b64f60
Author: ashermorgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Fri,  2 Apr 2021 12:33:43 -0700

Update scraper.py and add requirements.txt

Diffstat:
Ascripts/requirements.txt | 3+++
Mscripts/scraper.py | 14+++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/scripts/requirements.txt b/scripts/requirements.txt @@ -0,0 +1,3 @@ +beautifulsoup4 +openpyxl +requests diff --git a/scripts/scraper.py b/scripts/scraper.py @@ -16,22 +16,22 @@ def getConjugations(verb): soup = BeautifulSoup(page.text, "html.parser") # Get English infinative - english = soup.find("div", class_="CMxOwuaP _1v-p9pvd").text + english = soup.find("div", class_="quickdefWrapper--2qDMaLCj").text # Get participles - presentParticiple = soup.find_all("div", class_="_2xfncFkp")[0].text - pastParticiple = soup.find_all("div", class_="_2xfncFkp")[1].text + presentParticiple = soup.find_all("div", class_="dashedBorder--2zu1T3f5")[0].text + pastParticiple = soup.find_all("div", class_="dashedBorder--2zu1T3f5")[1].text # Get Indicative conjugations indicative = [] - rows = soup.find_all("table", class_="_2qmJM3i9")[0].find_all("tr") + rows = soup.find_all("table", class_="vtable--2WLTGmgs")[0].find_all("tr") for row in rows: cols = row.find_all("td") indicative += [[col.text for col in cols]] # Get Subjunctive conjugations subjunctive = [] - rows = soup.find_all("table", class_="_2qmJM3i9")[1].find_all("tr") + rows = soup.find_all("table", class_="vtable--2WLTGmgs")[1].find_all("tr") for row in rows: cols = row.find_all("td") subjunctive += [[col.text for col in cols]] @@ -70,8 +70,8 @@ def correctConjugations(filepath): for i in range(len(row)): if (temp[i] != None and temp[i].lower() != row[i].lower()): row[i] = temp[i].capitalize() - except: - print("Exception during {0}".format(row[1])) + except Exception as e: + print(f"Exception during {row[1]}: {e}") # Save csv with open(filepath, "w", newline="", encoding="utf-8") as f: