How lu1120/tibame_test works
Purpose and Scope
A Python-based data-collection repository centered on Taiwan transport/tourism data. It contains separate crawlers for TDX and media/blog sources, plus producer/worker scripts suggesting asynchronous or batch-oriented execution. Root JSON files and attraction_* files appear to be collected/exported artifacts.
Entry Points and Execution Roles
• TDX collection entry point: crawler/crawler_tdx.py
• Blog/media collection entry point: crawler/crawler_blog.py
• Job-producing scripts: crawler/producer.py, crawler/producer_mediaTW.py
• Worker consumers: crawler/worker.py
• Task definitions or task-specific dispatch: crawler/tasks_crawler_tdx.py, crawler/tasks_crawler_mediaTW.py
The expected control pattern is producer → task payload → worker → source-specific crawler → local output.
Source-Specific Crawling
TDX integration is isolated around crawler/crawler_tdx.py and crawler/tasks_crawler_tdx.py. The checked-in environment includes tdx_proxy, provided by motc-tdx-proxy, indicating integration with Taiwan Ministry of Transportation and Communications TDX APIs.
Media/Taiwan crawling is separated from TDX flow in crawler/crawler_blog.py, crawler/tasks_crawler_mediaTW.py, and crawler/producer_mediaTW.py. This boundary allows source-specific request, parsing, and scheduling behavior.
Configuration Boundary
crawler/config.py is the central likely location for crawler settings, credentials, endpoints, queue/broker configuration, or output parameters. Producer, worker, and crawler scripts should depend on this module rather than duplicating operational values.
Processing and Persistence Flow
Crawler outputs are persisted locally rather than through an evident database layer. Repository-level data includes data_d.json and trail_data.json; files named attraction_345040000g_* likely represent individual attraction records or raw/result snapshots. This makes filesystem/JSON the material persistence boundary and implies downstream consumers read generated files directly.
Runtime and Infrastructure
The runtime is Python 3.12, represented by crawler/myenv/pyvenv.cfg and crawler/myenv/bin/python. HTTP access is supported by checked-in requests and urllib3 packages. docker-compose-local.yml is the available local infrastructure definition and likely supports producer/worker dependencies; its exact services cannot be determined from the provided tree.
Architecture-Defining Components
1. Configuration: crawler/config.py
2. TDX ingestion: crawler/crawler_tdx.py
3. Blog/media ingestion: crawler/crawler_blog.py
4. TDX task orchestration: crawler/tasks_crawler_tdx.py
5. Media task orchestration: crawler/tasks_crawler_mediaTW.py
6. Producer-side dispatch: crawler/producer.py, crawler/producer_mediaTW.py
7. Worker-side execution: crawler/worker.py
8. JSON/file output dataset: data_d.json, trail_data.json
Main entry points: worker.py Worker · crawler_tdx.py TDX Crawler · config.py Crawler Config · crawler_blog.py Blog Crawler
Components 15
Job Dispatch
- TDX Producer
crawler/producer.py - Media Producer
crawler/producer_mediaTW.py - TDX Tasks
crawler/tasks_crawler_tdx.py - Media Tasks
crawler/tasks_crawler_mediaTW.py - Worker · Executes dispatched source-specific crawl work.
crawler/worker.py
Source Ingestion
- TDX Crawler
crawler/crawler_tdx.py - Blog Crawler
crawler/crawler_blog.py - Taiwan TDX APIs · Transport and tourism source accessed through the TDX integration.
- Blog & Media Sources
Local Data
- JSON Datasets · Collected and exported JSON data read directly from the filesystem.
data_d.json - Trail Dataset
trail_data.json - Attraction Exports · Individual attraction raw or result records.
Other components
- Crawler Config · Central settings for endpoints, credentials, queues, and output.
crawler/config.py - Local Infrastructure · Local producer/worker dependency definition.
docker-compose-local.yml - Python 3.12 Runtime
crawler/myenv/pyvenv.cfg
Connections 19
- TDX Producer → TDX Tasks: submits jobs
- Media Producer → Media Tasks: submits jobs
- TDX Tasks → Worker: task payloads
- Media Tasks → Worker: task payloads
- Worker → TDX Crawler: executes
- Worker → Blog Crawler: executes
- TDX Crawler → Taiwan TDX APIs: fetches transport data
- Blog Crawler → Blog & Media Sources: collects content
- TDX Crawler → JSON Datasets: writes results
- TDX Crawler → Trail Dataset: writes trail data
- TDX Crawler → Attraction Exports: writes attraction records
- Blog Crawler → JSON Datasets: writes results
- Crawler Config → TDX Producer: settings
- Crawler Config → Media Producer: settings
- Crawler Config → Worker: settings
- Crawler Config → TDX Crawler: settings
- Crawler Config → Blog Crawler: settings
- Local Infrastructure → Worker: local dependencies
- Python 3.12 Runtime → Worker: runs