Created
February 13, 2023 14:44
-
-
Save OlivierLaflamme/f6b1c6d0c0e52e7d38e206f2097e193c 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
import json | |
import re | |
import requests | |
import sys | |
import os | |
headers = { | |
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"} | |
fileurl=sys.argv[1] | |
filemkdir=fileurl.split('_')[0] | |
if not os.path.exists(filemkdir): | |
os.makedirs(filemkdir) | |
paths=[] | |
for dirpath, dirnames, filenames in os.walk('./'+filemkdir): | |
for file in filenames: | |
with open("./"+filemkdir+"/"+file,"r",encoding='gb18030', errors='ignore') as f2: | |
try: | |
line=f2.readlines() | |
for line in line: | |
line=line.strip('\n').strip('\t') | |
#print(line) | |
p = re.findall('''(['"]\/[^][^>< \)\(\{\}]*?['"])''',line) | |
#print(p) | |
if p != None: | |
#print(p) | |
for path in p: | |
path=path.replace(':"',"").replace('"',"") | |
paths.append(file+"---"+path) | |
except Exception as e: | |
print(e) | |
for var in sorted(set(paths)): | |
with open (fileurl+'_path.txt',"a+",encoding='gb18030', errors='ignore') as paths: | |
paths.write(var+'\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment