get-definitions: slow down big boy

This commit is contained in:
dece 2021-03-15 20:19:30 +01:00
parent fb43e28c6e
commit da64b59cfb

View file

@ -1,5 +1,6 @@
import os
import sys
import time
import urllib.parse
from pathlib import Path
@ -26,6 +27,7 @@ def main():
else:
start_from = ""
get_definitions(form)
time.sleep(5000)
except OSError:
exit("Could not open forms list file.")
@ -39,8 +41,7 @@ def get_definitions(form):
# Check other definitions.
tabs_bar = soup.find("div", id="vtoolbar")
if not tabs_bar:
sys.stderr.write("No tabs bar!\n")
return
exit("No tabs bar!\n")
num_defs = len(tabs_bar("li"))
for variant in range(1, num_defs): # skip the first, we got it above.
variant_url = url + f"/{variant}"
@ -60,8 +61,7 @@ def get_page(url):
def process_definition_page(soup, form, variant):
definition = soup.find("div", id="lexicontent")
if not definition:
sys.stderr.write("No definition!\n")
return
exit("No definition!\n")
save_definition(form, variant, definition.prettify())