Compare commits
15 Commits
c84141674a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 77f0d404fa | |||
| cf64bc4703 | |||
| ff022bce5d | |||
| 4ae6898be0 | |||
| 440416ba0c | |||
| 459a5299a0 | |||
| d4378afbc9 | |||
| dfb5fe0c89 | |||
| 384d7e4838 | |||
| e30292e330 | |||
| ec804afc60 | |||
| 4c48525b3a | |||
| b00a0c40d8 | |||
| 5ec4c38495 | |||
| 2d0eeaa78f |
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@@ -0,0 +1,13 @@
|
||||
# 构建镜像时不打进上下文(减小体积;数据在宿主机卷里)
|
||||
.git
|
||||
.env
|
||||
.env.*
|
||||
*.session
|
||||
*.session-journal
|
||||
state.json
|
||||
-100*/
|
||||
__pycache__
|
||||
*.pyc
|
||||
.cursor
|
||||
.venv
|
||||
venv
|
||||
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# ========== 密钥与登录(切勿提交到远程)==========
|
||||
.env
|
||||
.env.*
|
||||
*.session
|
||||
*.session-journal
|
||||
|
||||
# ========== 运行状态与抓取进度(与频道数据配套,勿提交)==========
|
||||
state.json
|
||||
|
||||
# ========== 按频道存放的抓取结果(SQLite、媒体、导出文件)==========
|
||||
# 目录名一般为 Telegram 超级群/频道 ID(-100xxxxxxxxxx)
|
||||
-100*/
|
||||
|
||||
# ========== 脚本生成的列表(可随时再生成)==========
|
||||
channels_list.csv
|
||||
|
||||
# ========== Python ==========
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.Python
|
||||
venv/
|
||||
.venv/
|
||||
*.egg-info/
|
||||
.eggs/
|
||||
dist/
|
||||
build/
|
||||
|
||||
# ========== 编辑器 / 本地工具 ==========
|
||||
.cursor/
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# ========== 日志与临时文件 ===========
|
||||
*.log
|
||||
*.tmp
|
||||
*.temp
|
||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
# 运行 Web 控制台;抓取数据通过卷挂载到 /data,见 docker-compose 说明
|
||||
FROM python:3.11-slim
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -U pip setuptools wheel \
|
||||
&& pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY telegram-scraper.py app_web.py ./
|
||||
COPY templates ./templates/
|
||||
COPY static ./static/
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "app_web:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
20
README.md
20
README.md
@@ -119,6 +119,26 @@ python telegram-scraper.py
|
||||
- **QR Code** (Recommended) - Scan with your phone (no phone number needed)
|
||||
- **Phone Number** - Traditional SMS verification
|
||||
|
||||
## Web Console (MVP) 🌐
|
||||
|
||||
You can run a simple web control panel that manages `.env` configuration and starts/stops the scraper process:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
uvicorn app_web:app --host 0.0.0.0 --port 8000 --reload
|
||||
```
|
||||
|
||||
Then open:
|
||||
|
||||
```text
|
||||
http://127.0.0.1:8000
|
||||
```
|
||||
|
||||
Features:
|
||||
- Edit core config values from the web page (saved back to `.env`)
|
||||
- Start / stop scraper process from browser
|
||||
- View recent runtime logs
|
||||
|
||||
## Usage 📝
|
||||
|
||||
The script provides a clean interactive menu:
|
||||
|
||||
1117
app_web.py
Normal file
1117
app_web.py
Normal file
File diff suppressed because it is too large
Load Diff
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# 用法(在项目根目录):
|
||||
# docker compose build
|
||||
# docker compose up -d
|
||||
# 数据持久化:把宿主机上的项目目录挂到 /data,与 app 内工作目录一致(见下方 volumes)
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
image: telegram-scraper-web:local
|
||||
container_name: telegram-scraper-web
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8000:8000"
|
||||
working_dir: /data
|
||||
volumes:
|
||||
# 改成你服务器上「已有代码 + .env + state + session + 各 -100* 目录」的绝对路径
|
||||
- ${HOST_PROJECT_DIR:-.}:/data
|
||||
command: ["uvicorn", "app_web:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -1,15 +1,10 @@
|
||||
aiohappyeyeballs==2.6.1
|
||||
aiohttp==3.12.14
|
||||
aiosignal==1.4.0
|
||||
asyncio==3.4.3
|
||||
attrs==25.3.0
|
||||
frozenlist==1.7.0
|
||||
idna==3.10
|
||||
multidict==6.6.3
|
||||
propcache==0.3.2
|
||||
pyaes==1.6.1
|
||||
pyasn1==0.6.1
|
||||
qrcode==8.0
|
||||
rsa==4.9.1
|
||||
Telethon==1.40.0
|
||||
yarl==1.20.1
|
||||
# 直接依赖(子依赖由 pip 自动解析)
|
||||
# 若仍装不上:请先执行 python3 --version,CentOS 自带 Python 3.6 过旧,建议安装 python39/python311 后再 pip install
|
||||
Telethon>=1.28.0,<2
|
||||
fastapi>=0.65.0,<1
|
||||
uvicorn>=0.17.0,<1
|
||||
itsdangerous>=2.0.0
|
||||
jinja2>=3.0.0,<4
|
||||
python-multipart>=0.0.5
|
||||
qrcode>=7.3.0
|
||||
PySocks>=1.7.0
|
||||
|
||||
BIN
static/favicon.png
Normal file
BIN
static/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 619 KiB |
File diff suppressed because it is too large
Load Diff
1564
templates/index.html
Normal file
1564
templates/index.html
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user