mirror of
https://github.com/m4rcel-lol/m5rcode.git
synced 2025-12-06 19:13:57 +05:30
Update cmd_wdir.py
This commit is contained in:
committed by
GitHub
parent
7ef4a4f20f
commit
56997509b2
@@ -23,15 +23,30 @@ class WdirCommand:
|
|||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
links = soup.find_all("a")
|
links = soup.find_all("a")
|
||||||
|
|
||||||
if not links:
|
files = []
|
||||||
print(Fore.YELLOW + "No directory listing or links found at this URL.")
|
dirs = []
|
||||||
|
|
||||||
|
for link in links:
|
||||||
|
href = link.get("href")
|
||||||
|
if not href or href.startswith("?") or href.startswith("#"):
|
||||||
|
continue
|
||||||
|
if href in ("../", "/"):
|
||||||
|
continue # skip parent link
|
||||||
|
if href.endswith("/"):
|
||||||
|
dirs.append(href)
|
||||||
|
else:
|
||||||
|
files.append(href)
|
||||||
|
|
||||||
|
if not files and not dirs:
|
||||||
|
print(Fore.YELLOW + "No directory listing found (site may not expose files).")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(Fore.CYAN + f"Directory listing for {self.url}:\n")
|
print(Fore.CYAN + f"Directory listing for {self.url}:\n")
|
||||||
for link in links:
|
|
||||||
href = link.get("href")
|
for d in dirs:
|
||||||
if href:
|
print(Fore.BLUE + f"[DIR] {d}")
|
||||||
print(Fore.GREEN + " - " + href)
|
for f in files:
|
||||||
|
print(Fore.GREEN + f"[FILE] {f}")
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(Fore.RED + f"Error fetching URL: {e}")
|
print(Fore.RED + f"Error fetching URL: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user