Skip to content

Latest commit

Β 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐝 DoiHive

DoiHive Logo

A cross-language (Python/Go) tool for batch downloading academic PDFs from DOIs

Currently supports extracting DOIs from Web of Science (WoS) exported TXT files and downloading PDFs via Sci-Hub

δΈ­ζ–‡ζ–‡ζ‘£ β€’ English


Overview

DoiHive automates the process of extracting DOIs from bibliographic data files and downloading corresponding PDFs. The project aims to eventually support automatic DOI retrieval from search queries, but currently focuses on processing existing DOI data.

Current Status: Both Python and Go implementations are complete with core functionality. Go version offers superior performance for large-scale downloads.

DoiHive Workflow

Vision: πŸ” Topic β†’ 🐝 OpenAlex β†’ 🏠 DOI List β†’ 🍯 Sci-Hub β†’ 🌾 Harvest β†’ πŸ“„ PDF β†’ πŸ€– AI Pipeline

End-to-end academic literature collection: from topic search to AI training data

Features

  • βœ… Extract DOIs from WoS TXT files, batch download PDFs
  • βœ… Anti-crawl: Browser headers, random delays, auto-retry
  • βœ… DOI cache: Resume support, skip processed DOIs
  • βœ… Safe harvest: Gradual downloading, auto-stop on anomalies
  • βœ… Real-time progress: Progress bar, statistics, log persistence

Tech Stack

Python Go

  • Python 3.13+ - Basic implementation
  • Go 1.25+ - High-performance implementation (recommended)

Performance Comparison

Metric Python Go (default 3 workers)
Time per task - ~400-600ms
Concurrency Single-threaded Goroutines
Throughput - ~2 DOI/s
Cache/Anti-crawl ❌ βœ…
Recommended for Small-scale testing Large-scale batch downloads

⚠️ Python version lacks cache and anti-crawl mechanisms, not recommended for large-scale downloads

Installation

Prerequisites

For Python:

  • Python 3.13 or higher
  • uv (recommended) or pip

For Go:

  • Go 1.25 or higher

Setup

  1. Clone the repository:

    git clone https://github.com/SJRnhqh/DoiHive.git
    cd DoiHive
  2. For Python: Install dependencies using uv:

    uv sync

    Or using pip:

    pip install -e .
  3. For Go: Install dependencies:

    go mod download

    Build the executable:

    ./build.sh

    Or build manually:

    go build -o bin/doihive ./cmd

Usage

Python Implementation

  1. Prepare WoS TXT files: Place your Web of Science exported TXT files in the archive/ directory.

  2. Run the script:

    cd python
    python main.py
  3. Output:

    • PDFs are saved to pdf/ directory
    • Error logs are saved to error/ directory (JSON format)
    • Application logs are saved to logs/ directory

Go Implementation (Recommended)

./bin/doihive-darwin-arm64 -a archive -b 100 -w 2
Option Description Default
-a Archive directory (required) -
-b Limit download count (0=all) 0
-w Concurrent workers 3
-pdf PDF output directory ./pdf

Output directories: pdf/ (PDFs), pdf/logs/ (logs), pdf/debug/ (debug)

Safe Harvest (Recommended for Large-Scale)

./scripts/harvest.sh -a ./archive                    # Default settings
./scripts/harvest.sh -a ./archive -b 50 -r 10        # 50 per batch, 10 rounds
Option Description Default
-a Archive directory (required) -
-b Batch size per round 30
-r Max rounds (0=unlimited) 0
-w Concurrent workers 3
-d Min delay between batches (sec) 60
-D Max delay between batches (sec) 180

Project Structure

DoiHive/
β”œβ”€β”€ python/                 # Python implementation
β”‚   β”œβ”€β”€ main.py            # Main entry point
β”‚   └── utils/             # Utility modules
β”‚       β”œβ”€β”€ analyze.py     # DOI extraction and validation
β”‚       β”œβ”€β”€ hive.py        # PDF download logic
β”‚       └── logger.py      # Logging configuration
β”œβ”€β”€ cmd/                   # Go implementation
β”‚   └── main.go            # Main entry point (CLI)
β”œβ”€β”€ core/                  # Go core logic
β”‚   β”œβ”€β”€ check.go           # DOI checking and extraction
β”‚   β”œβ”€β”€ hive.go            # PDF download logic (with cache & anti-crawl)
β”‚   └── logger.go          # Log persistence
β”œβ”€β”€ scripts/               # Automation scripts
β”‚   └── harvest.sh         # Safe gradual batch download script
β”œβ”€β”€ bin/                   # Compiled binaries (generated)
β”œβ”€β”€ archive/               # Input: WoS TXT files
β”œβ”€β”€ pdf/                   # Output: Downloaded PDFs
β”‚   β”œβ”€β”€ downloaded.txt     # Cache: successfully downloaded DOIs
β”‚   β”œβ”€β”€ not_available.txt  # Cache: unavailable DOIs on Sci-Hub
β”‚   β”œβ”€β”€ logs/              # Output: Download logs (Go)
β”‚   └── debug/             # Output: Debug HTML files
β”œβ”€β”€ error/                 # Output: Error logs (Python)
β”œβ”€β”€ logs/                  # Output: Application logs (Python)
β”œβ”€β”€ build.sh               # Cross-platform build script
β”œβ”€β”€ pyproject.toml         # Python dependencies
└── go.mod                 # Go dependencies

Development Roadmap

βœ… Completed

  • WoS TXT file DOI extraction & validation
  • Sci-Hub batch download (Python/Go dual implementation)
  • Anti-crawl: browser headers, random delays, auto-retry
  • DOI cache & resume support
  • Safe harvest script (gradual downloading)
  • Real-time progress bar & log persistence

🚧 Planned

  • Multiple Sci-Hub mirror support
  • Other bibliographic data sources
  • Configuration file support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Disclaimer

This tool is for educational and research purposes only. Please respect copyright laws and publisher terms of service when downloading academic papers.

About

🐝 Batch download academic PDFs from DOIs via Sci-Hub (Python/Go) (ι€šθΏ‡ Sci-Hub 从 DOI ζ‰Ήι‡δΈ‹θ½½ε­¦ζœ― PDFοΌŒζ”―ζŒ Python/Go)

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages