开源项目 images-web-crawler
使用教程
1. 项目的目录结构及介绍
images-web-crawler/
├── LICENSE
├── README.md
├── dataset_builder.py
├── images_downloader.py
├── sample.py
├── web_crawler.py
LICENSE
: 项目的许可证文件,采用 GPL-3.0 许可证。README.md
: 项目的说明文档,包含项目的基本介绍和使用方法。dataset_builder.py
: 用于构建数据集的脚本。images_downloader.py
: 用于下载图片的脚本。sample.py
: 示例脚本,展示如何使用项目功能。web_crawler.py
: 核心脚本,负责爬取网页并收集图片链接。
2. 项目的启动文件介绍
项目的启动文件是 sample.py
,它展示了如何使用 web_crawler.py
和 images_downloader.py
来爬取和下载图片。
# sample.py
from web_crawler import WebCrawler
crawler = WebCrawler(api_keys)
crawler.collect_links_from_web(keywords, images_nbr, remove_duplicated_links=True)
crawler.save_urls(download_folder + "/links.txt")
crawler.download_images(keywords, target_folder=download_folder)
3. 项目的配置文件介绍
项目没有明确的配置文件,但可以通过修改 sample.py
中的参数来配置爬虫的行为。
api_keys
: 用于访问某些 API 的密钥。keywords
: 要搜索的关键词列表。images_nbr
: 每个关键词要下载的图片数量。download_folder
: 图片下载的目标文件夹。
通过修改这些参数,可以定制爬虫的行为,例如更改搜索关键词、调整下载图片的数量等。