This Python script navigates through web server directory listings and optionally saves file details to a CSV file. It's designed to work with directory listings that follow a specific HTML structure typically found on web servers.
- Navigates through directory listings recursively.
- Prints directory and file details to the console.
- Optionally outputs file details (filename, URL, size, and last modified date) to a CSV file.
- Python 3.x
requests
librarybeautifulsoup4
library
Before running the script, ensure you have Python installed and then install the required Python packages:
pip install requests beautifulsoup4
Run the script from the command line, providing the URL of the directory listing:
python directory_listing_tree.py --url "https://example.com/path/to/directory"
To also save the results to a CSV file, add the --csv
flag:
python directory_listing_tree.py --url "https://example.com/path/to/directory" --csv
The CSV file will be named after the URL with slashes replaced by underscores.
- This script disables SSL warnings. Use it only on trusted sites and understand the security implications.
- Ensure the URL provided does not contain any sensitive or private information, as it's used in the CSV filename.
- The script assumes a specific HTML structure for the directory listings. It may require adjustments for other structures.
- Always test the script in a controlled environment before use.
Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.
Michael Ritter – @BigM1ke_oNe