Skip to content

Instantly share code, notes, and snippets.

@Hareric
Created May 23, 2021 08:43
Show Gist options
  • Save Hareric/9ea50261316eac7c048f4ff881fcfd30 to your computer and use it in GitHub Desktop.
Save Hareric/9ea50261316eac7c048f4ff881fcfd30 to your computer and use it in GitHub Desktop.
#!/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