adyoi commited on
Commit
cb6d2b7
·
verified ·
1 Parent(s): 3ff4730

Upload audit_kamus.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. audit_kamus.py +8 -3
audit_kamus.py CHANGED
@@ -24,15 +24,20 @@ def cek_pypi(word):
24
  return None
25
 
26
 
 
 
 
27
  def cek_web(word):
 
28
  import requests
29
 
30
  try:
 
 
 
31
  from urllib.parse import quote
32
 
33
- r = requests.get(
34
- f"https://kbbi.web.id/{quote(word)}", timeout=15, headers=UA
35
- )
36
  if r.status_code != 200:
37
  return None
38
  marker = "Maaf, tidak ditemukan kata yang dicari"
 
24
  return None
25
 
26
 
27
+ _SESI = None
28
+
29
+
30
  def cek_web(word):
31
+ global _SESI
32
  import requests
33
 
34
  try:
35
+ if _SESI is None:
36
+ _SESI = requests.Session()
37
+ _SESI.headers.update(UA)
38
  from urllib.parse import quote
39
 
40
+ r = _SESI.get(f"https://kbbi.web.id/{quote(word)}", timeout=15)
 
 
41
  if r.status_code != 200:
42
  return None
43
  marker = "Maaf, tidak ditemukan kata yang dicari"