diff options
| author | Eltrac <hi@guhub.cn> | 2025-05-23 15:17:31 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-05-23 15:17:31 +0800 |
| commit | d27c5ff896d63aa08d36b5b54be12b68ebd21e98 (patch) | |
| tree | 417b461ecdf45d51f2c83b594cf416c6a6d5efab | |
| parent | da127026553423f60b3bd76f0f2cc6883a288e86 (diff) | |
fix: link-graph.json cannot be found
Former-commit-id: d69e53b588ab131309c75c602e28c741ab5641a9
| -rw-r--r-- | extractLinks.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/extractLinks.py b/extractLinks.py index 8cd7695c..e1eaf2e3 100644 --- a/extractLinks.py +++ b/extractLinks.py @@ -166,11 +166,7 @@ def main(): collect_urls() build_link_graph() - nodes = [ - {"id": url, "label": title_map[url], "url": url} - for url in link_graph - ] - + nodes = [{"id": url, "label": label_map.get(url, url.strip("/").split("/")[-1]), "url": url} for url in link_graph] edges = [] for source, targets in link_graph.items(): for target in targets: @@ -178,9 +174,11 @@ def main(): graph = {"nodes": nodes, "edges": edges} - with open("static/link-graph.json", "w", encoding="utf-8") as f: + # ✅ 写入到 public/ + output_path = os.path.join("public", "link-graph.json") + with open(output_path, "w", encoding="utf-8") as f: json.dump(graph, f, indent=2, ensure_ascii=False) - print("✅ Link graph generated: link-graph.json") + print(f"✅ Link graph generated: {output_path}") if __name__ == "__main__": |
