npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@x1ngyu/lc-spider

v1.0.9

Published

Fetching the algorithm questions that have been accepted on own LeetCode account.

Downloads

13

Readme

Leetcode Spider

基于 nodejs 爬取 leetcode.cn 上已通过的题目,生成 markdown,并支持多种编程语言。如果传了多个编程语言,多次执行不会重复爬取同一题目和同一编程语言,但是该题目如果已经通过了,且其中某个编程语言未通过,仍然会爬取对应编程语言的算法。

使用

npm i @x1ngyu/lc-spider -g

lc-spider <path>

创建一个目录,在根目录下新建 lc-config.json ,或者在命令行中指定 config 文件,但必须是 json 格式。

{
  "username": "xxxxx",
  "password": "xxxxx",
  "output": "path",
  "languages": ["javascript"],
  "translate": false
}
  • username、password:leetcode.cn 账号密码。
  • output: markdown 输出的路径。default: ./questions
  • languages: 指定编程语言。e.g. c#、java、python、python3、c、ruby、javascript、go、swift、scala、kotlin
  • translate: 输出的 markdown 是否使用中文。true: zh、false: en。 defalut: true.

注意事项

单个算法题的最近提交的算法代码请求个数取决于 config.languages 中, 该算法已通过的编程语言个数。

例如:

{
  "languages": ["java", "javascript", "python3"]
}

两树之和的算法题,提交并通过了 java 和 javascript 的算法,那么该题会发送 2 个最近提交的算法代码请求。

由于 leetcode 限制了每分钟内最近提交的算法代码接口的请求个数,超过后将获取不到算法代码,因此分批并延迟去请求,爬取时间可能较长。如果最近提交的算法代码请求个数低于 50 ,将并发全部执行。否则每 20s 同时发送 10 个请求。