MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _extract_json_obj

Method _extract_json_obj

IntelOSINT.py:14691–14722  ·  view source on GitHub ↗
(blob, start_idx)

Source from the content-addressed store, hash-verified

14689 html = page.content()
14690 if html:
14691 def _extract_json_obj(blob, start_idx):
14692 i = start_idx
14693 while i < len(blob) and blob[i].isspace():
14694 i += 1
14695 if i >= len(blob) or blob[i] != '{':
14696 return ""
14697 depth = 0
14698 in_string = False
14699 esc = False
14700 quote = ""
14701 j = i
14702 while j < len(blob):
14703 ch = blob[j]
14704 if in_string:
14705 if esc:
14706 esc = False
14707 elif ch == "\\":
14708 esc = True
14709 elif ch == quote:
14710 in_string = False
14711 else:
14712 if ch in ("'", '"'):
14713 in_string = True
14714 quote = ch
14715 elif ch == '{':
14716 depth += 1
14717 elif ch == '}':
14718 depth -= 1
14719 if depth == 0:
14720 return blob[i:j + 1]
14721 j += 1
14722 return ""
14723
14724 def _extract_from_embedded_json(html_text):
14725 script_blobs = re.findall(r"<script[^>]*>(.*?)</script>", html_text, flags=re.DOTALL | re.IGNORECASE)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected