import json import os def generate_json_report(data, output_file="report.json"): """ Generates a JSON report of the site analysis. """ try: with open(output_file, 'w') as f: json.dump(data, f, indent=4) print(f"JSON report generated at {os.path.abspath(output_file)}") except Exception as e: print(f"Error generating JSON report: {e}") def generate_html_report(data, output_file="report.html"): """ Generates an HTML report for the domain scan. """ summary = data['summary'] details = data['details'] html = f""" SEO Image Alt Text Report

SEO Image Alt Text Report

{summary['total_pages_scanned']}

Pages Scanned

{summary['total_images_found']}

Total Images Found

{summary['total_images_missing_alt']}

Images Missing Alt Text

""" if summary.get('crawl_blocked'): html += f"""
⚠️ CRAWL BLOCKED: The crawler was blocked by the site ({summary.get('blocked_reason')}). Results are likely incomplete.

Try using a residential proxy or a headless browser with stealth plugins to bypass this restriction.

""" html += """

Detailed Breakdown

""" if not details: html += "

No pages found with missing alt text images! Great job.

" for page in details: html += f"""
Page: {page['page_url']}

{page['missing_alt_count']} images missing alt text

""" for img_src in page['images_without_alt']: html += f""" """ html += "
Image Source URL
{img_src}
" html += """
""" try: with open(output_file, 'w') as f: f.write(html) print(f"HTML report generated at {os.path.abspath(output_file)}") except Exception as e: print(f"Error generating HTML report: {e}")