Created
May 23, 2021 08:43
-
-
Save Hareric/9ea50261316eac7c048f4ff881fcfd30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright © 2021, All rights reserved. | |
# Author: Eric <wendachen@flickering.ai> | |
from pathlib import Path | |
import re | |
import json | |
dir_path = '/Users/har/Documents/Github/online-tools' | |
match_list = [] | |
pattern = "\"(https://cdn.jsdelivr.net/.*?)\"" | |
for file in Path(dir_path).rglob("*"): | |
if file.is_dir(): | |
continue | |
is_in_hide_folder = False | |
for p in file.parents: | |
if p.name.startswith('.'): | |
is_in_hide_folder = True | |
break | |
if is_in_hide_folder: | |
continue | |
try: | |
with open(file, "r+", encoding='utf-8') as f: | |
origin_data = f.read() | |
match_list += re.findall(pattern, origin_data) | |
except UnicodeDecodeError: | |
continue | |
print(list(set(match_list))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment