ygp-gdzwfw-gov-cn/README.md

65 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 广东省公共资源交易平台爬虫
本项目是一个 Python 爬虫程序,用于抓取 [广东省公共资源交易平台](https://ygp.gdzwfw.gov.cn/#/44/jygg) 的中标结果公告。
## 功能特性
- **关键字过滤**:自动筛选标题中包含“中标结果”的公告。
- **日期过滤**:支持指定开始和结束日期,默认为抓取当天数据。
- **自动分页**:自动处理多页数据抓取。
- **动态构造 URL**:根据接口返回字段自动生成可直接访问的详情页链接。
- **纯 HTTP 请求**:直接使用 aiohttp 调用官方 API无需浏览器轻量高效。
## 环境要求
- Python 3.8+
## 安装步骤
1. **克隆项目并进入目录**
```bash
cd ygp-gdzwfw-gov-cn
```
2. **创建并激活虚拟环境 (推荐)**
```bash
python3 -m venv venv
source venv/bin/activate # macOS/Linux
# 或 venv\Scripts\activate # Windows
```
3. **安装依赖**
```bash
pip install -r requirements.txt
```
## 使用方法
### 1. 抓取今天发布的数据 (默认)
直接运行脚本,程序将自动抓取发布日期为今天的“中标结果”公告。
```bash
python ygp_crawler.py
```
### 2. 抓取指定日期范围
使用 `--start-date``--end-date` 参数(格式:`YYYY-MM-DD`)。
```bash
python ygp_crawler.py --start-date 2026-02-01 --end-date 2026-02-04
```
### 3. 保存抓取结果
脚本将结果以 JSON 格式输出到控制台。可以使用重定向将其保存到文件中。
```bash
python ygp_crawler.py --start-date 2026-02-01 > results.jsonl
```
## 数据输出示例
```json
{
"项目标题": "某某项目中标结果公示",
"发布时间": "20260204173002",
"详细链接": "https://ygp.gdzwfw.gov.cn/#/44/new/jygg/v3/A?noticeId=..."
}
```