mirror of
https://github.com/Jieyab89/OSINT-Cheat-sheet.git
synced 2026-01-13 05:16:20 -08:00
fix web based
This commit is contained in:
@@ -3,11 +3,13 @@ import json
|
||||
import os
|
||||
|
||||
url = "https://raw.githubusercontent.com/Jieyab89/OSINT-Cheat-sheet/refs/heads/main/README.md"
|
||||
# URL (add another soon)
|
||||
|
||||
response = requests.get(url)
|
||||
data = response.text
|
||||
|
||||
json_file = "osint_data.json"
|
||||
json_file = os.path.join(os.pardir, "osint_data.json")
|
||||
|
||||
if os.path.exists(json_file):
|
||||
with open(json_file, "r", encoding="utf-8") as f:
|
||||
try:
|
||||
@@ -18,19 +20,18 @@ else:
|
||||
existing_data = []
|
||||
|
||||
existing_categories = {cat["category"]: cat for cat in existing_data}
|
||||
|
||||
new_categories = {}
|
||||
current_category = None
|
||||
|
||||
for line in data.split("\n"):
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith("# "):
|
||||
if line.startswith("# "):
|
||||
current_category = line[2:].strip()
|
||||
if current_category not in new_categories:
|
||||
new_categories[current_category] = {"category": current_category, "items": []}
|
||||
|
||||
elif line.startswith("- [") and "](" in line:
|
||||
elif line.startswith("- [") and "](" in line:
|
||||
parts = line.split("[", 1)[1].split("](")
|
||||
name = parts[0].strip()
|
||||
link = parts[1].split(")")[0].strip()
|
||||
@@ -50,4 +51,4 @@ for category, new_data in new_categories.items():
|
||||
with open(json_file, "w", encoding="utf-8") as f:
|
||||
json.dump(list(existing_categories.values()), f, indent=4, ensure_ascii=False)
|
||||
|
||||
print("Data updated: osint_data.json")
|
||||
print(f"Data updated: {json_file}")
|
||||
|
||||
Reference in New Issue
Block a user