An open API service indexing awesome lists of open source software.

https://github.com/aaronlmathis/leetscraper

Simple web scraper that gets the leetcode problem of the day (or any problem by number)
https://github.com/aaronlmathis/leetscraper

Last synced: 7 months ago
JSON representation

Simple web scraper that gets the leetcode problem of the day (or any problem by number)

Awesome Lists containing this project

README

          

# ๐Ÿง  LeetScraper
[![GitHub release](https://img.shields.io/github/v/release/aaronlmathis/leetscraper?label=Download)](https://github.com/aaronlmathis/leetscraper/releases/latest)

**LeetScraper** is a command-line tool that fetches the [LeetCode](https://leetcode.com) Daily Challenge (or any specific problem) and saves it as well-formatted, language-specific source files โ€” complete with problem description, difficulty, and starter code.

> ๐Ÿ”“ Open Source | ๐Ÿน Written in Go | ๐Ÿ“˜ GPL-3.0 Licensed

---

## โœจ Features

- โœ… Fetches **daily challenge** or specific problem by slug
- โœ… Outputs clean, readable **source files** with problem description
- โœ… Supports **multiple languages** (Go, Python, Java, Rust, etc.)
- โœ… Fully configurable with `--flags` or `~/.leetscraper.json`
- โœ… Clean CLI and **GitHub Actions-based release automation**

---

## ๐Ÿ“ฆ Installation

### ๐Ÿณ Download prebuilt binary

Precompiled binaries are available inside archives for major platforms:

- **Linux (x86_64)**: [leetscraper-linux.tar.gz](https://github.com/aaronlmathis/leetscraper/releases/latest/download/leetscraper-linux.tar.gz)
- **macOS (arm64)**: [leetscraper-darwin.tar.gz](https://github.com/aaronlmathis/leetscraper/releases/latest/download/leetscraper-darwin.tar.gz)
- **Windows (x86_64)**: [leetscraper-windows.zip](https://github.com/aaronlmathis/leetscraper/releases/latest/download/leetscraper-windows.zip)

Or visit the [Releases page](https://github.com/aaronlmathis/leetscraper/releases) to download and verify checksums.

```sh
# Example (Linux):
curl -LO https://github.com/aaronlmathis/leetscraper/releases/latest/download/leetscraper-linux.tar.gz
tar -xzf leetscraper-linux.tar.gz
chmod +x leetscraper
./leetscraper --help
```

### ๐Ÿ›  Or build from source:

```bash
git clone https://github.com/aaronlmathis/leetscraper.git
cd leetscraper
make build
./dist/leetscraper --help
```

---

## ๐Ÿš€ Usage

### โžค Daily Challenge (default)
Will default to pulling golang snippet, saving to working directory, using filename format: {id}-{difficulty}-{slug}.{ext} if .leetscraper.json is not present in home directory.
```bash
leetscraper
```

### โžค Specific Problem by Slug

```bash
leetscraper --slug two-sum
```

### โžค Custom Output Directory

```bash
leetscraper --out ~/leetcode/daily
```

### โžค Multiple Languages

```bash
leetscraper --langs golang,python3,rust
```
### โžค File Naming
```bash
leetscraper --format {id}-{difficulty}-{slug}.{ext}
```
---

## โš™๏ธ Configuration
Set your preferences (optional) via .leetscraper.json saved to home directory.

See `leetscraper.json.sample` for example.

`~/.leetscraper.json`:

```json
{
"outputDir": "/home/you/leetcode",
"filenameFormat": "{id}-{difficulty}-{slug}.{ext}",
"languages": ["golang", "python3"]
}
```

Command-line flags will **override** config file values.

---

## ๐Ÿ“ Output Example

```text
123-easy-two-sum.go
123-easy-two-sum.py
123-easy-two-sum.rs
```

Each file includes:

- Problem title, difficulty, and link
- Full problem description (Markdown)
- Starter function in your language(s)

---

## ๐Ÿ”ง Development

```bash
make build # Build binary into dist/
make test # Run integration tests
make release # Cross-compile for release
make package # Create .tar.gz and .zip archives
```

---

## ๐Ÿงช Test Example

```bash
./test/test_leetscraper.sh
```

Or run as part of `make test`.

---

## ๐Ÿ“œ License

**GPL-3.0-or-later**
ยฉ 2025 [Aaron Mathis](mailto:aaron.mathis@gmail.com)

---

## โญ๏ธ Star This Project

If this tool saves you time, consider [โญ starring the repo](https://github.com/aaronlmathis/leetscraper) โ€” it helps more developers discover it!