This release is a pre-release and may not be stable for production use.
GeodesyDataCollector
GeodesyDataCollector 是一个用于下载和管理大地测量相关公开科研数据的命令行工具。
它支持从 FTP 和 HTTPS 目录索引站点中批量抓取文件,提供目录浏览、递归搜索、正则匹配、多线程下载、断点续传和自动解压等功能。
功能特性
- 支持 FTP / HTTPS 两种数据源
- 支持命令行交互式操作
- 支持
cd、ls、pwd、get等常用命令 - 支持 通配符匹配 与 正则表达式匹配
- 支持 递归搜索子目录
- 支持 多线程下载
- 支持 断点续传
- 支持下载后 自动解压
- 支持解压后删除原压缩包
- 支持通过
config.yaml配置服务器别名和默认参数
项目结构
GeodesyDataCollector/
├── config/
│ └── config.yaml
├── output/
├── temp/
├── src/
│ └── gdc/
│ ├── cli.py
│ ├── downloader.py
│ ├── extractor.py
│ └── utils.py
├── pyproject.toml
├── requirements.txt
├── README.md
├── MANIFEST.in
├── LICENSE
└── .gitignore
---
## 环境要求
- Python 3.9 或更高版本
- 建议使用虚拟环境
- 依赖库:
- `requests`
- `beautifulsoup4`
- `PyYAML`
- `tqdm`
---
## 安装依赖
### 使用 pip 安装
```bash
pip install -r requirements.txt
使用虚拟环境(推荐)
python -m venv .venv
source .venv/bin/activate # Linux / macOS
# .venv\Scripts\activate # Windows
pip install -r requirements.txt
安装为可执行命令
如果你已经配置了 pyproject.toml,可以使用以下方式安装本项目:
pip install -e .
安装完成后,可以直接运行:
gdc
配置说明
项目默认读取 config/config.yaml。
示例配置
settings:
dir_output: "/Users/yourname/GeodesyDataCollector/output/"
dir_temp: "/Users/yourname/GeodesyDataCollector/temp/"
default_threads: 4
aliases:
itsg: https://ftp.tugraz.at/pub/ITSG/
gfz: https://isdc-data.gfz.de/
配置项说明
settings.dir_output
下载文件保存目录。
settings.dir_temp
临时下载文件保存目录。
settings.default_threads
默认下载线程数。
aliases
服务器别名配置,便于快速连接。
例如:
connect itsg
等价于:
connect https://ftp.tugraz.at/pub/ITSG/
使用方法
启动交互式命令行:
python src/gdc/cli.py
或者安装后直接运行:
gdc
命令说明
1. 连接服务器
connect itsg
connect https://ftp.tugraz.at/pub/ITSG/
connect ftp://user:password@host/path/
2. 查看当前目录
pwd
3. 列出当前目录内容
ls
4. 切换目录
cd GRACE
cd ITSG-Grace_operational
cd ..
cd /pub/ITSG/
5. 下载文件
普通下载
get "*.gfc"
使用正则表达式
get -r ".*\.gfc"
递归搜索并下载
get -R "*.gfc"
递归 + 正则
get -R -r "monthly_n(60|96)/.*\.gfc"
多线程下载
get -t 4 -R "*.gfc"
下载后自动解压
get -e "*.zip"
解压后删除压缩包
get -e -d "*.zip"
指定输出子目录
get -o itsg_data "*.gfc"
示例流程
下载 ITSG GRACE 数据
connect itsg
pwd
ls
cd GRACE
ls
cd ITSG-Grace_operational
ls
get -R -r ".*\.gfc"
下载 monthly 目录下的文件
connect itsg
cd GRACE/ITSG-Grace_operational/monthly
get "*.gfc"
常见问题
1. cd 成功后,get -R 仍然扫描到上层目录
通常是路径归一化或递归目录筛选逻辑有问题。
本项目在 downloader.py 中已经加入:
- 当前目录标准化
visited去重- 父目录链接过滤
- 仅允许当前目录子树递归
2. ls 返回空列表
可能原因:
- 目标目录不存在
- 网站目录索引不是标准 HTML 列表
- 服务器限制访问频率
- 网络连接失败
建议先用浏览器打开对应 URL,确认目录页是否可访问。
3. 下载文件不完整
本项目支持断点续传,但并非所有 FTP/HTTP 服务器都支持 Range 或 REST 断点续传。 如果服务器不支持,下载可能会重新开始。
4. 正则没有匹配到文件
正则匹配的是相对路径字符串,不是只匹配文件名。 例如:
get -r "monthly_n60/.*\.gfc"
比单纯的:
get -r ".*\.gfc"
更精确。
开发说明
主要模块
-
cli.py -
命令行交互入口
-
downloader.py -
FTP/HTTPS 下载逻辑
-
文件列表递归遍历
-
extractor.py -
压缩包解压逻辑
-
utils.py -
工具函数预留模块
许可证
本项目采用 MIT License。
致谢
感谢以下开源库和公开科研数据源:
- Python
requests - Python
ftplib BeautifulSoup4tqdm- ITSG / GFZ 等公开大地测量数据服务站点
免责声明
本工具仅用于访问公开可用的科研数据资源。 请遵守数据提供方的使用条款、访问限制与版权要求。
Metadata
Release files for geodesy-data-collector 0.1.1a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| geodesy_data_collector-0.1.1a3.tar.gz | 18.7 kB | Without provenance | Details for geodesy_data_collector-0.1.1a3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geodesy_data_collector-0.1.1a3-py3-none-any.whl | Python 3 | none | any | Details for geodesy_data_collector-0.1.1a3-py3-none-any.whl |
Total release size: 34.3 kB
Release files / geodesy_data_collector-0.1.1a3.tar.gz
| Download URL | geodesy_data_collector-0.1.1a3.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
561df8ae9c48c8ad797c4311eb6c75b3acb77755d90e797946d2a52853613148
|
|
BLAKE2b-256 checksum How to use checksums |
48406bba5381f174ed9584f93188d69d2210933acd7393b85c0a7b65e8886281
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / geodesy_data_collector-0.1.1a3-py3-none-any.whl
| Download URL | geodesy_data_collector-0.1.1a3-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76b4ba67f433e7c6a02b227b87117d1cd6b859c4bc1779a019c77d8920444876
|
|
BLAKE2b-256 checksum How to use checksums |
6c0dff2e19c3fffb23b3c96f797ba80222de62cd3c2ab0ccecd5051453f7ed74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for geodesy-data-collector 0.1.1a3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.