crawlbaseDocs
Anmelden
Zähler werden oberhalb von tausend gerundet

LeetCode kürzt Upvote-, Aufruf- und Kommentarzahlen ab, sobald sie tausend überschreiten - 11.9K, 2.3M. Diese werden zurück in Ganzzahlen expandiert, ein Wert wie 11900 trägt also die von der Seite gezeigte Genauigkeit und nicht die exakte Zahl.

API-Nutzung

Fügen Sie &scraper=leetcode-solutions zu einem Crawling-API-Request hinzu. Kodieren Sie die Ziel-URL im Parameter url URL-encoded.

curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
  --data-urlencode 'url=https://leetcode.com/problems/two-sum/solutions/' \
  --data-urlencode 'scraper=leetcode-solutions' -G
from crawlbase import CrawlingAPI

api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
    'https://leetcode.com/problems/two-sum/solutions/',
    {'scraper': 'leetcode-solutions'}
)

import json
data = json.loads(res['body'])
const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });

const res = await api.get(
  'https://leetcode.com/problems/two-sum/solutions/',
  { scraper: 'leetcode-solutions' }
);
const data = JSON.parse(res.body);
require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')

res = api.get('https://leetcode.com/problems/two-sum/solutions/', scraper: 'leetcode-solutions')
data = JSON.parse(res.body)

Beispiel-Eingabe-URL

Im Parameter url funktioniert der Lösungs-Tab jeder LeetCode-Aufgabe - die Seite unter /problems/<slug>/solutions/. Zum Beispiel:

https://leetcode.com/problems/two-sum/solutions/
https://leetcode.com/problems/add-two-numbers/solutions/
https://leetcode.com/problems/valid-parentheses/solutions/

Response-Struktur

JSON-Response-Body. Feldtypen können null sein, wenn die Quellseite den Wert nicht enthält.

url
string
URL der gescrapten Lösungsliste.
problem
string | null
Slug der Aufgabe, zu der die Lösungen gehören.
problemUrl
string | null
Absolute URL der Aufgabenseite.
solutionCount
integer
Anzahl der Einträge, die für diese Seite in solutions zurückgegeben werden.
solutions
array
Auf der Seite gefundene Lösungsbeiträge, in der aufgeführten Reihenfolge.
solutions[].title
string | null
Titel des Beitrags.
solutions[].url
string | null
Absolute URL des Beitrags.
solutions[].id
string | null
Beitrags-ID aus der URL, als String zurückgegeben.
solutions[].author
object
Konto, das den Beitrag veröffentlicht hat.
solutions[].author.name
string | null
Angezeigter Autorenname.
solutions[].author.username
string | null
Profil-Handle des Autors.
solutions[].author.url
string | null
Absolute URL des Autorenprofils.
solutions[].postedAt
string | null
Veröffentlichungsdatum wie auf der Karte angezeigt.
solutions[].tags
array
Tag-Chips auf der Karte - Themen und Sprachen - als Array von Strings.
solutions[].upvotes
integer | null
Anzahl der Upvotes auf den Beitrag.
solutions[].views
integer | null
Anzahl der Aufrufe des Beitrags.
solutions[].comments
integer | null
Anzahl der Kommentare zum Beitrag.

Beispiel-Response

{
  "url": "https://leetcode.com/problems/two-sum/solutions/",
  "problem": "two-sum",
  "problemUrl": "https://leetcode.com/problems/two-sum/",
  "solutionCount": 15,
  "solutions": [
    {
      "title": "Two Sum",
      "url": "https://leetcode.com/problems/two-sum/solutions/127810/two-sum-by-leetcode-kwuq/",
      "id": "127810",
      "author": {
        "name": "LeetCode",
        "username": "leetcode",
        "url": "https://leetcode.com/u/leetcode/"
      },
      "postedAt": "Jun 25, 2021",
      "tags": [
        "Editorial"
      ],
      "upvotes": 5000,
      "views": 13800000,
      "comments": 2700
    },
    {
      "title": "✅3 Method's || C++ || JAVA || PYTHON || Beginner Friendly🔥🔥🔥",
      "url": "https://leetcode.com/problems/two-sum/solutions/3619262/3-methods-c-java-python-beginner-friendl-x595/",
      "id": "3619262",
      "author": {
        "name": "Rahul Varma",
        "username": "rahulvarma5297",
        "url": "https://leetcode.com/u/rahulvarma5297/"
      },
      "postedAt": "Jun 09, 2023",
      "tags": [
        "Array",
        "Hash Table",
        "C++",
        "Java"
      ],
      "upvotes": 11900,
      "views": 2300000,
      "comments": 285
    }
  ]
}