Skip to main content

一个强大的Google图片爬虫工具

Project description

GlimCrawl

PyPI version Python Version License

English | 简体中文

一个强大的 Google 图片爬虫工具,支持批量下载、图片处理和代理设置。名称来源:glimpse(一瞥)+ crawl(爬行),强调"快速捕捉网络图片片段"。

✨ 特性

  • 🚀 异步并发下载,提高效率
  • 🎨 自动图片处理和优化(去水印、调整大小等)
  • 🌐 支持代理设置,解决网络问题
  • 📏 支持图片尺寸和时间筛选
  • 🖥️ 命令行界面,易于使用
  • 📦 支持作为 Python 库导入使用
  • 🔒 安全可靠,遵循 Google 搜索规范
  • 📁 灵活的目录管理(支持关键词子目录、目录存在处理等)

📦 安装

# 从 PyPI 安装(推荐)
pip install glimcrawl

# 安装 Playwright 浏览器(必需)
playwright install chromium

🚀 快速开始

命令行使用

# 基本使用
glimcrawl download "猫咪"

# 指定下载数量和保存目录
glimcrawl download "猫咪" -l 50 -d ./images

# 使用代理
glimcrawl download "猫咪" -p http://127.0.0.1:1080

# 筛选大图和最近图片
glimcrawl download "猫咪" -s l -t w

# 禁用关键词子目录
glimcrawl download "猫咪" --no-keyword-dir

# 目录已存在时跳过创建
glimcrawl download "猫咪" -e skip

Python 库使用

import asyncio
from glimcrawl import GoogleImageCrawler
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        crawler = GoogleImageCrawler(browser)
        # 下载 20 张猫咪图片到 images 目录
        await crawler.crawl_images("猫咪", max_images=20, save_dir="images")
        await browser.close()

asyncio.run(main())

📝 参数说明

命令行参数

参数 说明 默认值 示例
keyword 搜索关键词(必需) - "猫咪"
-l, --limit 最大下载数量 100 -l 50
-d, --save-dir 保存目录 images -d ./images
--use-keyword-dir/--no-keyword-dir 是否使用关键词创建子目录 True --no-keyword-dir
-e, --if-exists 目录已存在时的处理方式 rename -e skip
-p, --proxy 代理服务器 None -p http://127.0.0.1:1080
-s, --size 图片尺寸 None -s l (大图)
-t, --date 时间范围 None -t w (一周内)

图片尺寸选项

  • l: 大图
  • m: 中图
  • i: 图标

时间范围选项

  • d: 24小时内
  • w: 一周内
  • m: 一月内
  • y: 一年内

🛠️ 图片处理

下载的图片会自动进行以下处理:

  1. 格式转换:统一转为 JPG 格式
  2. 尺寸调整:最大 1920x1080,保持比例
  3. 质量优化:85% 压缩率
  4. 文件命名:使用 MD5 哈希,避免重复
  5. 去水印:自动识别和移除水印(实验性功能)

🔒 安全建议

  1. 使用代理时建议配置 HTTPS 代理
  2. 遵循目标网站的爬虫规范
  3. 合理设置下载间隔和并发数
  4. 图片仅供学习研究使用

🤝 贡献

  1. Fork 本仓库
  2. 创建新分支: git checkout -b feat/new-feature
  3. 提交更改: git commit -am 'feat: add new feature'
  4. 推送分支: git push origin feat/new-feature
  5. 提交 Pull Request

📄 许可证

MIT License © 2024 Duckweeds7

📋 更新日志

v0.1.1 (2024-04-20)

  • ✨ 新增目录管理功能
    • 支持使用关键词创建子目录
    • 支持目录已存在时的处理策略(跳过/覆盖/重命名)
    • 优化目录创建和文件保存逻辑
  • 🐛 修复已知问题
    • 修复目录已存在时的处理逻辑
    • 优化文件命名和保存机制
  • 📝 更新文档
    • 添加新功能使用说明
    • 完善参数说明
    • 更新示例代码

v0.1.0 (2024-04-19)

  • 🎉 首次发布
    • 支持基本的图片下载功能
    • 支持图片处理和优化
    • 支持代理设置
    • 支持命令行界面

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glimcrawl-0.1.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glimcrawl-0.1.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file glimcrawl-0.1.1.tar.gz.

File metadata

  • Download URL: glimcrawl-0.1.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for glimcrawl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4fd7a12769d7ccd51d3444eb5b670f321a6a17bda2d7a5d5389d304261123cf6
MD5 4b2d39ceb42d49f6289b28c36f908be7
BLAKE2b-256 07237ad3744b11e62468216efd3609f5f74640c777b1556f0f79da8a6e766e1a

See more details on using hashes here.

File details

Details for the file glimcrawl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: glimcrawl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for glimcrawl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9630194779284e1d06cdaa5b5342f002722a37a83dae506fb877b144b358aca
MD5 5c2f1082a724e36b0774625b0f27a405
BLAKE2b-256 7225357f39dbc6dedd95247efaf9eea54e1d3547a2de28fb5e4e2fbe6f5a5d26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page