Access LeetCode problems via id

Overview

LCid - access LeetCode problems via id

Introduction

As a world's leading online programming learning platform, LeetCode is quite popular among programmers. Since each problem has a unique number id, users tend to share problems via id. However, it is not convenient to visit problem page directly via id. People have to visit LeetCode Problems firstly, then enter that number id in the 'Search questions' input box, press 'enter', click the problem title link, finally comes to the problem page. What a hard work!

This simple project, called LCid, provides directly access to LeetCode problems via id. Features:

  • Fetch all LeetCode problems via crwaler.
  • Redirect to LeetCode problem page with problem id in the URL path via backend.
  • Support both LeetCode global site and China site redirect.
  • CI/CD, fetch all LeetCode problems daily and commit back to repository via Git Action, then trigger backend rebuild and redeploy with the latest problems via Heroku.

LCid is now available at lcid.cc. Just add / at the end of lcid.cc (e.g. lcid.cc/1), then browser will redirect you to the problem page. Simple, fast, and make your live easier.

What's more, to redirect to China site, add /cn/ instead (e.g. lcid.cc/cn/1). Interested in the brief info of the problem? Try /info/ (e.g. lcid.cc/info/1) and find more!

Environment

To start LCid on your local machine, you should have python 3.7+ installed.

The crawler is implemented with urllib3 and backend is powered with flask.

To install all those dependencies, execute pip install -r requirements.

Usage

Fetch All Problems

To fetch all problems, execute python fetch_problems_all.py. Then, you will see the logs below.

Now try get csrftoken...
Got csrftoken fakecsrftokenfakecsrftokenfakecsrftokenfakecsrftokenfakecsrftoke.
Found 2060 problems in total.
Now try fetch all 2060 LeetCode problems...
All 2060 problems fetched.
All 2060 problems info saved into problems_all.json file.

After few seconds, all problems info have been saved into problems_all.json file in json format.

Start Backend Service

To start backend service, execute python app.py (e.g. python app.py 1437). Then, the backend server will start at localhost: .

Now you can try the following endpoints. All of them should work correctly.

  • localhost: /
  • localhost: /1
  • localhost: /cn/1
  • localhost: /info/1

Deployment

To deploy the system for public access, of course, you can use any platform you like. Here, I use GitHub Actions and Heroku.

  • GitHub Actions is used to fetch all LeetCode problems daily (execute python fetch_problems_all.py, get the latest problems_all.json) and commit back to repository. You would know how it works by analysing this config file.
  • Heroku would rebuild and redeploy the backend service once main branch of this repository changed. This can be configured at Deploy - Automatic deploys in your Heroku app dashboard.
  • Heroku also support add additional domains to visit app. Here is the official guide.

Disclaimer

  • This is just a naive tool for convenient access and only call LeetCode API at low frequency. It only obtains public accessible data (no personal info or paid content collected and distributed). DO NOT ABUSE LEETCODE API!!!
  • GitHub Repo: bunnyxt/lcid
  • Author: bunnyxt
  • License: MIT
You might also like...
Role Based Access Control for Slack-Bolt Applications

Role Based Access Control for Slack-Bolt Apps Role Based Access Control (RBAC) is a term applied to limiting the authorization for a specific operatio

Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and other financial information. This repository provides an SDK for developing applications to access the NCDS.

Nasdaq Cloud Data Service (NCDS) Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and ot

The Research PACS on AWS solution facilitates researchers' access medical images stored in the clinical PACS in a secure and seamless manner
The Research PACS on AWS solution facilitates researchers' access medical images stored in the clinical PACS in a secure and seamless manner

Research PACS on AWS Challenge to solve Solution presentation Deploy the solution Further reading Releases License Challenge to solve The rise of new

Repository to access information of stocks in Bombay Stock Exchange.

BSE Repository to access information of stocks in Bombay Stock Exchange. The code in this repository uses BSE API and conclusions made using the code

Unofficial instagram API, give you access to ALL instagram features (like, follow, upload photo and video and etc)! Write on python.

Instagram-API-python Unofficial Instagram API to give you access to ALL Instagram features (like, follow, upload photo and video, etc)! Written in Pyt

Basic query to access Traindex API

traindex-api-query Basic query to access Traindex API Please make sure to provide your Traindex API key to the line 8 in the script file. There are tw

This bot  automaticaly access to giveaway ! You can won free NFT !
This bot automaticaly access to giveaway ! You can won free NFT !

This bot automaticaly access to giveaway ! You can won free NFT !

File-sharing-Bot: Telegram Bot to store Posts and Documents and it can Access by Special Links.

File-sharing-Bot Telegram Bot to store Posts and Documents and it can Access by Special Links. I Guess This Will Be Usefull For Many People..... 😇 .

A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key).

fulltmdb A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key). Installation Use the package manager pip t

Owner
bunnyxt
Full Stack Developer, Student at University of Southern California
bunnyxt
OGE-2022-na-Python - Solving problems in python for the OGE 2022

OGE-2022-na-Python Решение задачек на питоне для ОГЭ 2022 Тут разобраны разные в

Slava 0 Oct 14, 2022
An API Client package to access the APIs for NBA.com

nba_api An API Client package to access the APIs for NBA.com Development Version: v1.1.9 nba_api is an API Client for www.nba.com. This package is mea

Swar Patel 1.4k Jan 1, 2023
PyMed is a Python library that provides access to PubMed.

IMPORTANT NOTE: I don't have time to maintain this library (as some of you might have noticed). The PubMed API is a little chaotic, without a clear do

Gijs Wobben 143 Dec 21, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
A minimalistic library designed to provide native access to YNAB data from Python

pYNAB A minimalistic library designed to provide native access to YNAB data from Python. Install The simplest way is to install the latest version fro

Ivan Smirnov 92 Apr 6, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
A Python library to access Instagram's private API.

Instagram Private API A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs. Overview I wr

null 2.6k Jan 5, 2023
Validate all your Customer IAM Policies against AWS Access Analyzer - Policy Validation

✅ Access Analyzer - Batch Policy Validator This script will analyze using AWS Access Analyzer - Policy Validation all your account customer managed IA

Victor GRENU 41 Dec 12, 2022
Telegram Bot to store Posts and Documents and it can Access by Special Links.

File-sharing-Bot Telegram Bot to store Posts and Documents and it can Access by Special Links. I Guess This Will Be Usefull For Many People..... ?? .

Code X Botz 1.2k Jan 8, 2023
Automation for grabbing keys from a Linux host. Useful during red team exercises to quickly help assess what access to a Linux host can lead to.

keygrabber Automation for grabbing keys from a Linux host. This can be helpful during red team exercises when you gain access to a Linux host and want

Cedric Owens 14 Sep 27, 2022