Skip to content

Instantly share code, notes, and snippets.

@OlivierLaflamme
Created February 13, 2023 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OlivierLaflamme/f6b1c6d0c0e52e7d38e206f2097e193c to your computer and use it in GitHub Desktop.
Save OlivierLaflamme/f6b1c6d0c0e52e7d38e206f2097e193c to your computer and use it in GitHub Desktop.
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