Skip to content

Commit

Permalink
Perjelas pesan ketika entri tidak ditemukan
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Jan 3, 2018
1 parent 23f7444 commit 26f3960
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kbbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class TidakDitemukan(Exception):
'''
Galat yang menunjukkan bahwa entri tidak ditemukan dalam KBBI.
'''
def __init__(self):
Exception.__init__(self, 'Entri tidak ditemukan dalam KBBI!')
def __init__(self, keyword):
Exception.__init__(self, keyword + ' tidak ditemukan dalam KBBI!')

def __init__(self, keyword):
url = 'https://kbbi.kemdikbud.go.id/entri/{}'.format(quote(keyword))
url = 'https://kbbi.kemdikbud.go.id/entri/' + quote(keyword)
raw = requests.get(url).text
if "Entri tidak ditemukan." in raw:
raise self.TidakDitemukan
raise self.TidakDitemukan(keyword)
self.arti = []
self.arti_contoh = []
isolasi = raw[raw.find('<h2>'):raw.find('<h4>')]
Expand Down

0 comments on commit 26f3960

Please sign in to comment.