diff --git a/README.md b/README.md index 69854d4..5631cff 100644 --- a/README.md +++ b/README.md @@ -206,13 +206,18 @@ Ensure you have **Python 3.12 or later** installed before proceeding with the in ```bash python3 --version -``` +``` + +Subdominator core modules doesn't include PDF generation dependency, if you fancy a PDF report, use PDF extra tags when installing: +```bash +pipx install 'subdominator[PDF]' +``` #### ✅ **Install Subdominator from PyPI** (Recommended) The easiest way to install Subdominator is via PyPI: ```bash -pip install --upgrade subdominator +pip install --upgrade 'subdominator[PDF]' ``` #### ✅ **Install the Latest Version from GitHub** @@ -226,13 +231,13 @@ pip install --upgrade git+https://github.com/RevoltSecurities/Subdominator To avoid dependency conflicts, you can install Subdominator using `pipx`: ```bash -pipx install subdominator +pipx install 'subdominator[PDF]' ``` To install the latest version from GitHub with `pipx`: ```bash -pipx install git+https://github.com/RevoltSecurities/Subdominator +pipx install 'subdominator[PDF] @ git+https://github.com/RevoltSecurities/Subdominator' ``` #### ✅ **Install from Git Source** (For Development) @@ -242,7 +247,7 @@ For users who want to contribute or modify the tool, clone and install directly git clone https://github.com/RevoltSecurities/Subdominator.git cd Subdominator pip install --upgrade pip -pip install -r requirements.txt +pip install -e . # or pip install -e ".[PDF]" to support PDF report generation ``` After installation, you can verify if Subdominator is installed correctly by running: diff --git a/setup.py b/setup.py index 6b99a55..aeda1e3 100644 --- a/setup.py +++ b/setup.py @@ -30,9 +30,13 @@ 'setuptools>=75.6.0', 'SQLAlchemy>=2.0.32', 'tldextract>=5.1.2', - 'weasyprint>=65.0', 'aiosqlite>=0.21.0', ], + extra_require={ + "PDF": [ + 'weasyprint>=65.0', + ], + }, entry_points={ 'console_scripts': [ 'subdominator = subdominator.subdominator:main' diff --git a/subdominator/modules/shell/shell.py b/subdominator/modules/shell/shell.py index 45ae80c..1d0b39f 100644 --- a/subdominator/modules/shell/shell.py +++ b/subdominator/modules/shell/shell.py @@ -9,7 +9,6 @@ from rich.console import Console from rich.table import Table from jinja2 import Environment, FileSystemLoader -from weasyprint import HTML console = Console() @@ -191,7 +190,6 @@ async def generate_report(self,domain,output_file,format_type): console.print(f"[bold green]HTML report saved as {output_file}[/bold green]") elif format_type.lower() == "pdf": self.generate_pdf_report(html_report, output_file) - console.print(f"[bold green]PDF report saved as {output_file}[/bold green]") else: console.print(f"[bold yellow]Report generation only supports pdf/html format, please use a valid report generation format.[/bold yellow]") return @@ -201,7 +199,14 @@ def generate_html_report(self, report_data, template_path): return template.render(domain=report_data["domain"], subdomains=report_data["subdomains"]) def generate_pdf_report(self,html_report, output_file): + try: + from weasyprint import HTML + except ModuleNotFoundError: + console.print("[bold red]PDF report requires weasyprint module[/bold red]") + console.print("[bold green]Hint:[/bold green] pip install 'subdominator[PDF]'") + return HTML(string=html_report).write_pdf(output_file) + console.print(f"[bold green]PDF report saved as {output_file}[/bold green]") def load_subdomains_from_file(self, filename): if not os.path.exists(filename): @@ -228,4 +233,4 @@ async def do_help(self): [bold][green]help[/green][/bold] [bold]- Show this help menu[/bold] [bold][green]System Commands[/green][/bold] [bold]- ls, clear, pwd, cd, cat, echo, mkdir, rm, cp, mv[/bold] """ - ) \ No newline at end of file + )