Image_web_scraper / index.html
Anirudh1950's picture
Publish project page
a470be9 verified
Raw History Blame Contribute Delete
6.24 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Image web scraper</title>
<style>
:root { --bg:#f7f7f5; --fg:#1b1b1b; --muted:#666; --card:#fff; --line:#e3e3df; --accent:#2f6fde; --code:#f0f0ec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg:#141414; --fg:#eee; --muted:#9a9a9a; --card:#1e1e1e; --line:#333; --accent:#6c9cff; --code:#262626; } }
:root[data-theme="dark"] { --bg:#141414; --fg:#eee; --muted:#9a9a9a; --card:#1e1e1e; --line:#333; --accent:#6c9cff; --code:#262626; }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:15px/1.6 system-ui, -apple-system, Segoe UI, sans-serif; }
main { max-width:960px; margin:0 auto; padding:24px 16px 48px; }
header h1 { margin:0 0 4px; font-size:1.7rem; }
header p { margin:0 0 14px; color:var(--muted); }
.links { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:18px; }
.links a { background:var(--accent); color:#fff; text-decoration:none; padding:7px 13px; border-radius:8px; }
.links a.ghost { background:transparent; color:var(--fg); border:1px solid var(--line); }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:18px; margin-bottom:16px; overflow-wrap:anywhere; }
.gallery { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:10px; }
.gallery figure { margin:0; }
.gallery img { width:100%; border-radius:8px; border:1px solid var(--line); background:#0001; }
.gallery figcaption { font-size:.8rem; color:var(--muted); }
#readme img { max-width:100%; }
#readme pre { background:var(--code); padding:12px; border-radius:8px; overflow-x:auto; }
#readme code { background:var(--code); padding:1px 4px; border-radius:4px; }
#readme pre code { padding:0; }
#readme table { border-collapse:collapse; display:block; overflow-x:auto; }
#readme th, #readme td { border:1px solid var(--line); padding:4px 8px; }
a { color:var(--accent); }
</style>
</head>
<body>
<main>
<header>
<h1>Image web scraper</h1>
<p>CLI tool to bulk-download images by keyword</p>
</header>
<div class="links">
<a href="https://huggingface.co/Anirudh1950/Image_web_scraper">Code &amp; files on Hugging Face</a>
<a class="ghost" href="https://github.com/rudzz1950/Image_web_scraper">GitHub</a>
</div>
<div class="card" id="gallery-card" hidden><div class="gallery" id="gallery"></div></div>
<div class="card" id="readme"></div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.2/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.6/purify.min.js"></script>
<script>
const README = "# Google Image Scraper\n\nA simple and efficient command-line tool to download images from Google Images using Python. This script allows you to quickly gather images for your machine learning, computer vision, or any other project that requires image datasets.\n\n## Features\n\n- Download multiple images with a single command\n- Supports custom download directory\n- Multi-threaded downloads for improved performance\n- Automatic file type detection\n- Progress bar for download tracking\n- Cross-platform support (Windows, Linux, macOS)\n\n## Prerequisites\n\n- Python 3.6 or higher\n- pip (Python package manager)\n\n## Installation\n\n1. Clone the repository:\n ```bash\n git clone https://github.com/rudzz1950/Web-scraper.git\n cd Web-scraper\n ```\n\n2. Install the required dependencies:\n ```bash\n pip install -r requirements.txt\n ```\n\n## Usage\n\nBasic usage:\n```bash\npython scraper.py \"search query\"\n```\n\n### Options\n\n- `-c, --count`: Number of images to download (default: 10)\n- `-d, --directory`: Directory to save downloaded images (default: Downloads/google-image-scraper/)\n- `-t, --threads`: Number of download threads to use (default: 4)\n\n### Examples\n\n1. Download 20 images of cats:\n ```bash\n python scraper.py \"cats\" -c 20\n ```\n\n2. Download 50 images of dogs to a custom directory:\n ```bash\n python scraper.py \"dogs\" -c 50 -d /path/to/save/directory\n ```\n\n3. Use 8 threads for faster downloads:\n ```bash\n python scraper.py \"mountains\" -c 30 -t 8\n ```\n\n## Output\n\nDownloaded images will be saved in the following structure:\n```\n<download_directory>/\n\u2514\u2500\u2500 <search_query>/\n \u251c\u2500\u2500 image1.jpg\n \u251c\u2500\u2500 image2.jpg\n \u2514\u2500\u2500 ...\n```\n\n## Dependencies\n\n- requests - For making HTTP requests\n- tqdm - For progress bars\n- filetype - For file type detection\n\n## License\n\nThis project is open source and available under the [MIT License](LICENSE).\n\n## Disclaimer\n\nThis tool is for educational purposes only. Please respect copyright laws and terms of service of the websites you're scraping. The developers are not responsible for any misuse of this tool.\n\n## Running it\n\nThis tool queries Google Images, which blocks cloud servers, so run it locally: `pip install -r requirements-original.txt && python scraper.py \"cats\" -c 50`.\n\n";
const IMAGES = [];
const BASE = 'https://huggingface.co/Anirudh1950/Image_web_scraper/resolve/main/';
const el = document.getElementById('readme');
el.innerHTML = DOMPurify.sanitize(marked.parse(README));
// Relative image links in the README point at files in the model repo.
el.querySelectorAll('img').forEach(img => {
const src = img.getAttribute('src') || '';
if (!/^(https?:|data:)/.test(src)) img.src = BASE + src.replace(/^\.?\//, '').split('/').map(encodeURIComponent).join('/');
});
if (IMAGES.length) {
document.getElementById('gallery-card').hidden = false;
document.getElementById('gallery').innerHTML = IMAGES.map(p => {
const url = BASE + p.split('/').map(encodeURIComponent).join('/');
const cap = p.split('/').pop().replace(/\.[^.]+$/, '').replace(/[_-]+/g, ' ');
return `<figure><a href="${url}" target="_blank" rel="noopener"><img loading="lazy" src="${url}" alt=""></a><figcaption>${cap}</figcaption></figure>`;
}).join('');
}
</script>
</body>
</html>