Metadata-Version: 2.4
Name: nsfc-spider
Version: 0.1.2
Summary: 国自然大数据平台智能爬虫 - AI驱动的基金项目数据采集工具
Project-URL: Homepage, https://github.com/yourusername/nsfc-spider
Project-URL: Documentation, https://github.com/yourusername/nsfc-spider#readme
Project-URL: Repository, https://github.com/yourusername/nsfc-spider
Project-URL: Issues, https://github.com/yourusername/nsfc-spider/issues
Author-email: NSFC Spider Team <nsfc-spider@example.com>
License-File: LICENSE
Keywords: data-mining,funding,nsfc,research,scraper,spider
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.11
Requires-Dist: browser-use>=0.11.0
Requires-Dist: openai>=1.0.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: playwright>=1.40.0
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-docx>=1.0.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# NSFC Spider - 国自然大数据平台智能爬虫

🕷️ AI驱动的国家自然科学基金项目数据采集工具

基于 [browser-use](https://github.com/browser-use/browser-use) 框架，使用大语言模型智能理解网页结构，自动适应页面变化。

## 特性

- 🤖 AI 驱动：使用 LLM 理解网页，自动适应页面变化
- 💬 对话式 CLI：交互式命令行界面
- 🔧 灵活配置：支持多种 LLM 提供商
- 📊 结构化输出：JSON/CSV/Markdown 格式导出

## 安装

### 方式一：使用 pip 安装（推荐）

```bash
# 1. 安装包
pip install nsfc-spider

# 2. 安装浏览器
playwright install chromium
```

### 方式二：从源码安装

```bash
# 1. 克隆仓库
git clone https://github.com/yourusername/nsfc-spider.git
cd nsfc-spider

# 2. 安装依赖
pip install -e .

# 3. 安装 Playwright 浏览器
playwright install chromium
```

## 配置

### 快速配置（推荐）

安装后首次运行，使用交互式配置：

```bash
nsfc-spider
```

在 CLI 中输入 `/config` 按提示配置 LLM API。

### 手动配置

创建配置文件 `config/.env` 或 `.env`：

```env
# LLM 配置
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o
LLM_API_KEY=your-api-key-here
LLM_BASE_URL=https://api.openai.com/v1

# 浏览器配置
HEADLESS=false
```

**获取 API Key**：
- OpenAI: https://platform.openai.com/api-keys
- Anthropic: https://console.anthropic.com/
- DeepSeek: https://platform.deepseek.com/

详细配置说明请查看 [配置指南](docs/CONFIGURATION.md)。

## 快速开始

### 使用命令行工具

```bash
# 安装后直接运行
nsfc-spider

# 或使用 Python 模块方式
python -m nsfc_spider.cli
```

### 开发模式运行

```bash
# 从源码目录运行
cd nsfc-spider
python run.py
```

## CLI 命令

```
nsfc> help          # 查看帮助
nsfc> config        # 配置 LLM 和浏览器
nsfc> search 智慧港口    # 搜索项目
nsfc> search 人工智能 -p 3  # 搜索并爬取3页
nsfc> task <自然语言任务>   # 执行自定义任务
nsfc> status        # 查看配置状态
nsfc> exit          # 退出
```

## 支持的 LLM

- OpenAI (gpt-4o, gpt-4o-mini)
- Anthropic (claude-sonnet-4)
- DeepSeek
- Ollama (本地模型)

## 项目结构

```
nsfc-spider/
├── src/nsfc_spider/
│   ├── __init__.py
│   ├── agent.py      # Agent 封装
│   ├── config.py     # 配置管理
│   ├── cli/          # CLI 模块
│   └── tasks/        # 爬取任务
│       ├── direct_scraper.py   # 直接爬取
│       ├── nsfc_search.py      # AI搜索
│       ├── analyzer.py         # 数据分析
│       ├── llm_filter.py       # LLM筛选
│       └── review_generator.py # 综述生成
├── config/
│   └── .env.example
├── tests/            # 测试文件
├── docs/             # 文档
├── run.py            # 开发入口
├── main.py           # 打包入口
└── pyproject.toml    # 项目配置
```

## 文档

- 📖 [安装指南](docs/INSTALLATION.md) - 详细的安装步骤
- 🔧 [配置指南](docs/CONFIGURATION.md) - 环境变量和 API 配置
- 📚 [使用指南](docs/USAGE.md) - 完整的功能说明和示例
- 🤝 [贡献指南](docs/CONTRIBUTING.md) - 如何参与项目开发
- 🚀 [发布指南](docs/RELEASE.md) - 版本发布流程

## 许可证

MIT License - 详见 [LICENSE](LICENSE) 文件

## 贡献

欢迎提交 Issue 和 Pull Request！查看 [贡献指南](docs/CONTRIBUTING.md) 了解详情。

## 更新日志

查看 [CHANGELOG.md](CHANGELOG.md) 了解版本更新历史。

## 致谢

- [browser-use](https://github.com/browser-use/browser-use) - 核心浏览器自动化框架
- [Playwright](https://playwright.dev/) - 浏览器控制
- 所有贡献者和用户

## 联系方式

- 📦 PyPI: https://pypi.org/project/nsfc-spider/
- 🐛 问题反馈: [GitHub Issues](https://github.com/yourusername/nsfc-spider/issues)
