{"id":50445727,"url":"https://github.com/devsimsek/web2ebook","last_synced_at":"2026-05-31T21:30:45.717Z","repository":{"id":328257980,"uuid":"1114833997","full_name":"devsimsek/web2ebook","owner":"devsimsek","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-12T18:55:43.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-21T00:02:07.648Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devsimsek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-12T00:36:59.000Z","updated_at":"2025-12-12T18:55:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/devsimsek/web2ebook","commit_stats":null,"previous_names":["devsimsek/web2ebook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devsimsek/web2ebook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsimsek%2Fweb2ebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsimsek%2Fweb2ebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsimsek%2Fweb2ebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsimsek%2Fweb2ebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devsimsek","download_url":"https://codeload.github.com/devsimsek/web2ebook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsimsek%2Fweb2ebook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33750474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-31T21:30:40.680Z","updated_at":"2026-05-31T21:30:45.712Z","avatar_url":"https://github.com/devsimsek.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web2Ebook\n\nConvert web pages into beautiful, readable ebook formats (EPUB, PDF, MOBI) while preserving styling and metadata.\n\n**Copyright (c) devsimsek**\n\n\u003e **Note:** This code was generated using a proprietary LLM created and experimented on by devsimsek.\n\n## Features\n\n✨ **Multiple Format Support**\n- EPUB (widely compatible)\n- PDF (universal format)\n- MOBI (Kindle format, requires Calibre)\n\n🎨 **Style Preservation**\n- Maintains text formatting and structure\n- Embeds images directly into ebooks\n- Professional typography for reading\n- Beautiful code block styling with dark theme\n\n📚 **Smart Content Extraction**\n- Automatically identifies main content\n- Removes navigation, ads, and clutter\n- Extracts and preserves metadata\n- Filters out non-HTML files (images, PDFs, etc.)\n\n🕷️ **Multi-Page Crawling**\n- Crawl and combine multiple pages into one ebook\n- Each page becomes a chapter\n- Automatic table of contents generation\n- Smart link following within same domain\n\n🎭 **Cover Generation**\n- Automatically generates beautiful covers from metadata\n- Option to use custom cover images\n- Gradient backgrounds with elegant typography\n\n📝 **Metadata Support**\n- Extracts title, author, description\n- Preserves publication date and publisher\n- Supports Open Graph and meta tags\n\n## Installation\n\n### Prerequisites\n\n1. **Python 3.7+** is required\n\n2. **For MOBI conversion** (optional): Install [Calibre](https://calibre-ebook.com/)\n   - macOS: `brew install --cask calibre`\n   - Ubuntu/Debian: `sudo apt-get install calibre`\n   - Windows: Download from https://calibre-ebook.com/download\n\n### Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\nOr install individually:\n\n```bash\npip install requests beautifulsoup4 lxml ebooklib reportlab Pillow html2text\n```\n\n## Usage\n\n### Basic Usage\n\nConvert a web page to all formats (EPUB, PDF, MOBI):\n\n```bash\npython web2ebook.py https://example.com/article\n```\n\n### Crawl Multiple Pages\n\nCrawl and combine multiple pages into one ebook:\n\n```bash\npython web2ebook.py https://example.com/tutorial --crawl --max-pages 10\n```\n\n### Exclude URLs from Crawling\n\n**Exclude specific URLs:**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --exclude https://example.com/login https://example.com/contact\n```\n\n**Use wildcard patterns:**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --exclude '*/comments' '*login*' '*/tag/*'\n```\n\n**Load exclusions from file:**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --exclude-file exclude.txt\n```\n\nExample `exclude.txt`:\n```\n# Exclude login and admin pages\nhttps://example.com/login\nhttps://example.com/admin/*\n\n# Exclude by pattern\n*comment*\n*/tag/*\n*/category/*\n```\n\n### Include URLs for Targeted Crawling\n\n**Include specific URLs only (whitelist):**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --include https://example.com/chapter-1.html https://example.com/chapter-2.html\n```\n\n**Use wildcard patterns to target specific content:**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --include '*/chapter-*.html' 'https://example.com/docs/guide/*'\n```\n\n**Load inclusions from file:**\n```bash\npython web2ebook.py https://example.com/docs \\\n  --crawl \\\n  --include-file include.txt\n```\n\nExample `include.txt`:\n```\n# Only crawl chapters, skip navigation\nhttps://example.com/chapter-*.html\n*/tutorial/part-*.html\n\n# Or specific pages\nhttps://example.com/intro.html\nhttps://example.com/conclusion.html\n```\n\n**Combine include and exclude:**\n```bash\n# Include all chapters but exclude appendix chapters\npython web2ebook.py https://example.com/book \\\n  --crawl \\\n  --include '*/chapter-*.html' \\\n  --exclude '*/chapter-appendix-*.html'\n```\n\n### Specify Output Formats\n\nConvert to specific formats only:\n\n```bash\n# EPUB only\npython web2ebook.py https://example.com/article --formats epub\n\n# PDF and EPUB\npython web2ebook.py https://example.com/article --formats pdf epub\n```\n\n### Custom Output Directory\n\n```bash\npython web2ebook.py https://example.com/article -o /path/to/output\n```\n\n### Cover Options\n\n**Disable auto-generated cover:**\n```bash\npython web2ebook.py https://example.com/article --no-cover\n```\n\n**Use custom cover image:**\n```bash\npython web2ebook.py https://example.com/article --cover my_cover.png\n```\n\n### Target Specific Content with CSS Selectors\n\n**Target specific container:**\n```bash\npython web2ebook.py https://example.com/article \\\n  --content-selector \"article.post-content\"\n```\n\n**Remove unwanted elements:**\n```bash\npython web2ebook.py https://example.com/article \\\n  --exclude-selectors \".comments\" \".sidebar\" \"#ads\"\n```\n\n**Combined example:**\n```bash\n# Get article content, remove comments and ads\npython web2ebook.py https://blog.example.com/post \\\n  --content-selector \"article\" \\\n  --exclude-selectors \".comments\" \".related-posts\" \"aside\"\n```\n\n**Common examples:**\n```bash\n# Medium article\npython web2ebook.py https://medium.com/@user/article \\\n  --content-selector \"article\" \\\n  --exclude-selectors \".pw-responses\" \"aside\"\n\n# Dev.to post\npython web2ebook.py https://dev.to/user/post \\\n  --content-selector \"#article-body\" \\\n  --exclude-selectors \".comments\"\n\n# Documentation site\npython web2ebook.py https://docs.example.com/guide \\\n  --content-selector \".docs-content\" \\\n  --exclude-selectors \"nav\" \".toc\" \".breadcrumbs\"\n```\n\nSee [SELECTORS.md](SELECTORS.md) for complete CSS selector guide.\n\n### Complete Example\n\n```bash\npython web2ebook.py \\\n  https://example.com/my-article \\\n  --formats epub pdf \\\n  --output ./ebooks \\\n  --cover custom_cover.jpg \\\n  --crawl \\\n  --max-pages 20 \\\n  --exclude-file exclude.txt \\\n  --content-selector \"article\" \\\n  --exclude-selectors \".comments\" \".ads\"\n```\n\n## Command-Line Options\n\n```\npositional arguments:\n  url                   URL of the web page to convert\n\noptional arguments:\n  -h, --help            Show help message and exit\n  -f, --formats {epub,pdf,mobi}\n                        Output formats (default: all formats)\n  -o, --output OUTPUT   Output directory (default: current directory)\n  --no-cover            Do not generate a cover image\n  --cover COVER         Path to custom cover image\n  --crawl               Crawl and convert multiple pages into one ebook\n  --max-pages N         Maximum number of pages to crawl (default: 10)\n  --exclude [URL ...]   URLs or patterns to exclude from crawling\n  --exclude-file FILE   File containing URLs to exclude (one per line)\n  --include [URL ...]   URLs or patterns to include when crawling (whitelist)\n  --include-file FILE   File containing URLs to include (one per line)\n  --content-selector    CSS selector for main content (e.g., \"article\", \"#main\")\n  --exclude-selectors   CSS selectors for elements to remove (e.g., \".comments\")\n```\n\n## How It Works\n\n1. **Download**: Fetches the web page content\n2. **Extract**: Identifies main content and removes clutter\n3. **Parse**: Extracts metadata (title, author, date, etc.)\n4. **Process**: Cleans HTML and normalizes styling\n5. **Generate**: Creates cover image (if enabled)\n6. **Convert**: Produces ebook files in requested formats\n\n## Output Examples\n\nWhen you run:\n```bash\npython web2ebook.py https://example.com/article\n```\n\nYou'll get:\n```\nArticle_Title.epub\nArticle_Title.pdf\nArticle_Title.mobi\n```\n\n## Supported Websites\n\nWeb2Ebook works with most websites, but performs best with:\n\n- Blog posts and articles\n- Documentation pages\n- News articles\n- Tutorial pages\n- Long-form content\n\nIt automatically detects and extracts content from common HTML structures and metadata formats (Open Graph, Schema.org, etc.).\n\n## Styling\n\n### EPUB\n- Clean, readable typography\n- Justified text alignment\n- Proper heading hierarchy\n- Responsive images\n- Preserved links\n\n### PDF\n- Letter-size pages (8.5\" x 11\")\n- Professional margins\n- Title page with metadata\n- Page breaks between sections\n- Embedded cover image\n\n### MOBI\n- Kindle-optimized format\n- Converted from EPUB\n- Compatible with Kindle devices and apps\n\n## Dependencies\n\n- **requests**: HTTP library for downloading pages\n- **beautifulsoup4**: HTML parsing and manipulation\n- **lxml**: Fast XML and HTML parser\n- **ebooklib**: EPUB file creation\n- **reportlab**: PDF generation\n- **Pillow**: Image processing and cover generation\n- **html2text**: HTML to formatted text conversion\n- **Calibre** (optional): Required for MOBI conversion\n\n## Troubleshooting\n\n### MOBI conversion fails\n\nMake sure Calibre is installed and `ebook-convert` is in your PATH:\n\n```bash\n# Test if ebook-convert is available\nebook-convert --version\n```\n\nIf not found, install Calibre and add it to your PATH.\n\n### Font errors on cover generation\n\nThe script tries multiple font locations. If you get font warnings, it will fall back to default fonts. The cover will still be generated successfully.\n\n### SSL/Certificate errors\n\nIf you encounter SSL errors, you may need to update your SSL certificates:\n\n```bash\npip install --upgrade certifi\n```\n\n### Page download fails\n\n- Check your internet connection\n- Verify the URL is accessible\n- Some sites may block automated requests\n\n## Advanced Usage\n\n### As a Python Module\n\nYou can also use Web2Ebook in your Python scripts:\n\n```python\nfrom web2ebook import Web2Ebook\n\n# Basic conversion\nconverter = Web2Ebook('https://example.com/article')\nresults = converter.convert(formats=['epub', 'pdf'])\n\n# With options\nconverter = Web2Ebook(\n    url='https://example.com/article',\n    output_dir='./output',\n    generate_cover=True,\n    custom_cover='my_cover.png'\n)\nresults = converter.convert(formats=['epub'])\n\nprint(f\"EPUB created: {results['epub']}\")\n```\n\n### Custom Processing\n\nYou can also use individual components:\n\n```python\nfrom web2ebook import WebPageDownloader, MetadataExtractor, CoverGenerator\n\n# Download page\ndownloader = WebPageDownloader('https://example.com/article')\nhtml = downloader.download()\n\n# Extract metadata\nfrom bs4 import BeautifulSoup\nsoup = BeautifulSoup(html, 'html.parser')\nextractor = MetadataExtractor(soup, 'https://example.com/article')\nmetadata = extractor.extract()\n\n# Generate cover\ncover_gen = CoverGenerator(metadata)\ncover_gen.generate('cover.png')\n```\n\n## Contributing\n\nContributions are welcome! Feel free to:\n\n- Report bugs\n- Suggest features\n- Submit pull requests\n- Improve documentation\n\n## License\n\nCopyright (c) devsimsek\n\n## Support\n\nFor issues, questions, or suggestions, please open an issue on the repository.\n\n## Changelog\n\n### Version 1.0.0\n- Initial release\n- EPUB, PDF, and MOBI support\n- Automatic cover generation\n- Metadata extraction\n- Style preservation\n- Content cleaning and extraction\n\n## Acknowledgments\n\nBuilt with:\n- [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/) for HTML parsing\n- [ebooklib](https://github.com/aerkalov/ebooklib) for EPUB generation\n- [ReportLab](https://www.reportlab.com/) for PDF creation\n- [Calibre](https://calibre-ebook.com/) for MOBI conversion\n- [Pillow](https://python-pillow.org/) for image processing\n\n## Credits\n\nThis project was generated using a proprietary LLM created by devsimsek as part of ongoing AI experimentation.\n\n---\n\n**Made with ❤️ by devsimsek**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsimsek%2Fweb2ebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsimsek%2Fweb2ebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsimsek%2Fweb2ebook/lists"}