jonathanjordan21 commited on
Commit
96a0ae1
·
verified ·
1 Parent(s): 8a84171

Update extract.py

Browse files
Files changed (1) hide show
  1. extract.py +8 -8
extract.py CHANGED
@@ -142,16 +142,16 @@ def get_vehicle_info_bs4(nopol: str):
142
  all_rows = soup.find_all("div", class_="row")
143
  total_tagihan = []
144
  for row in all_rows:
145
- # if row.find_parent(id="det_pkb") or row.find_parent(id="det_swd"):
146
- # continue # skip rows inside det_pkb or det_swd
147
  if not ("POKOK" in row.text or "DENDA" in row.text or "TOTAL" in row.text):
148
  ps = row.find_all("p")
149
- # if len(ps) >= 3 and all(keyword in ps[i].text for i, keyword in enumerate(["Pokok", "Denda", "Total"])):
150
- total_tagihan.append({
151
- "pokok": ps[0].get_text(strip=True),
152
- "denda": ps[1].get_text(strip=True),
153
- "total": ps[2].get_text(strip=True)
154
- })
155
 
156
  # === 3. Rincian PKB ===
157
  rincians_pkb = []
 
142
  all_rows = soup.find_all("div", class_="row")
143
  total_tagihan = []
144
  for row in all_rows:
145
+ if row.find_parent(id="det_pkb") or row.find_parent(id="det_swd"):
146
+ continue
147
  if not ("POKOK" in row.text or "DENDA" in row.text or "TOTAL" in row.text):
148
  ps = row.find_all("p")
149
+ if len(ps) >= 4:
150
+ total_tagihan.append({
151
+ "pokok": ps[0].get_text(strip=True),
152
+ "denda": ps[1].get_text(strip=True),
153
+ "total": ps[2].get_text(strip=True)
154
+ })
155
 
156
  # === 3. Rincian PKB ===
157
  rincians_pkb = []