Grote push
This commit is contained in:
parent
59a757c72a
commit
63dd187fb4
6 changed files with 112 additions and 75 deletions
|
@ -23,6 +23,9 @@ def converteer(tekst, gebruiker=True):
|
|||
|
||||
from urllib import parse
|
||||
|
||||
if tekst is None:
|
||||
return None
|
||||
|
||||
if gebruiker:
|
||||
return parse.unquote(tekst).replace('_', ' ').split('#')[0]
|
||||
else:
|
||||
|
@ -131,8 +134,6 @@ def run(taal, start, stop):
|
|||
Paden kunnen gecontroleerd worden met https://www.xefer.com/wikipedia, al doet dit niets met 'speciale' Wikipedia-
|
||||
links.
|
||||
|
||||
>>> run('fr', 'Langue', 'Philosophie')
|
||||
|
||||
Gewone controles
|
||||
>>> run('en', "Belgium", "Philosophy")
|
||||
{'pad': ['Belgium', 'Northwestern Europe', 'Subregion', 'Region', 'Geography', 'Science', 'Scientific method', 'Empirical evidence', 'Proposition', 'Logic', 'Reason', 'Consciousness', 'Sentience', 'Emotion', 'Mental state', 'Mind', 'Phenomenon', 'Immanuel Kant', 'Philosophy']}
|
||||
|
@ -140,6 +141,8 @@ def run(taal, start, stop):
|
|||
{'pad': ['Department of Standards Malaysia', 'Ministry of International Trade and Industry (Malaysia)', 'Ministry (government department)', 'Executive (government)', 'Government', 'State (polity)', 'Germans', 'Germany', 'Central Europe', 'Europe', 'Continent', 'Landmass', 'Region', 'Geography', 'Science', 'Scientific method', 'Empirical evidence', 'Proposition', 'Logic', 'Reason', 'Consciousness', 'Sentience', 'Emotion', 'Mental state', 'Mind', 'Phenomenon', 'Immanuel Kant', 'Philosophy']}
|
||||
>>> run('en', 'Malkajgiri mandal', 'Philosophy')
|
||||
{'pad': ['Malkajgiri mandal', 'Medchal–Malkajgiri district', 'District', 'Administrative division', 'Sovereign state', 'Polity', 'Politics', 'Decision-making', 'Psychology', 'Science', 'Scientific method', 'Empirical evidence', 'Proposition', 'Logic', 'Reason', 'Consciousness', 'Sentience', 'Emotion', 'Mental state', 'Mind', 'Phenomenon', 'Immanuel Kant', 'Philosophy']}
|
||||
>>> run('fr', 'Langue', 'Philosophie')
|
||||
{'pad': ['Langue', 'Système', 'Ensemble', 'Mathématiques', 'Connaissance', 'Notion', 'Connaissance (philosophie)', 'Philosophie']}
|
||||
|
||||
Loops
|
||||
>>> run('nl', 'België', 'Philosophy')
|
||||
|
@ -148,7 +151,8 @@ def run(taal, start, stop):
|
|||
{'pad': ['Tom Inglesby', 'Johns Hopkins Center for Health Security', 'Nonprofit organization', 'Contract failure']}
|
||||
|
||||
Doodlopende eindes
|
||||
TODO Voorbeelden zoeken
|
||||
>>> run('en', 'Gaumee Film Awards', 'Philosophy')
|
||||
{'error': "Er konden geen nieuwe links meer gevonden worden op 'Gaumee Film Awards'"}
|
||||
|
||||
Foute linkjes
|
||||
>>> run('en', 'Deze pagina bestaat niet', 'Philosophy')
|
||||
|
@ -166,7 +170,7 @@ def run(taal, start, stop):
|
|||
|
||||
# Stoppen indien het inladen van de pagina niet lukte.
|
||||
if pagina.status_code != 200:
|
||||
return {'error': f"Er ging iets fout bij het inladen van '{lijst[-1]}'. Bestaat de website?"}
|
||||
return {'error': f"Er ging iets fout bij het inladen van '{lijst[-1]}', vertrekkende vanaf '{lijst[0]}'. Bestaat de website?"}
|
||||
|
||||
# Verwerken.
|
||||
soep = BeautifulSoup(pagina.content, 'html.parser')
|
||||
|
|
Reference in a new issue