Skip to main content

sololearnlib

sololearnlib is a library for retrieving public data from Sololearn.

  • Easy to use.
  • Lightweight.
  • Object Oriented.
  • Json-compatible data.

Features

  • Retrieve Blog articles.
  • Get Leaderboard data.
  • Retrieve 'Hot Today' codes from Code Playground.
  • Find out what are the trending, most recent and most popular codes.
  • Retrieve 'Hot Today' discussions.
  • Find out what are the trending, most recent and unanswered discussions.

Tech

sololearn just uses bs4 (BeautifulSoup4).

Installation

sololearnlib requires Python 3 v3.5+ to run.

$ pip install sololearnlib

Usage

Retrieve Blog data

  • Import
from sololearnlib import Blog
  • Create a class object.
blog = Blog()
  • Using methods/functions
# Get data about all the articles.
articles = blog.get_articles()
# {'getTopics': {'success': 1, 'errors': [...], 'data': [...]},
#  'getBlogPosts': {'paging': {...}, 'success': 1, 'errors': 
#   [...], 'data': [...]}}

Retrieve Code Playground Data

  • Import
from sololearnlib import CodePlayground
  • Create a class object.
ground = CodePlayground()
  • Using methods/functions
# Get hot codes.
hot = ground.get_hot_today()
# [{'😄Pure css Emoji😄😊': 'https://code.sololearn.com
#   /WVo6hshrJ3p6/#'}, {'⚔️Assasin Custom UI Cover ⚔️': 
#   'https://code.sololearn.com/WdNImK2M9ush/#'}, ...]

# Get all other codes.
codes = ground.get_codes()
# [{'code_link': 'https://code.sololearn.com/WZmG081162lG/#',
#   'code_name': 'Water sort puzzle game 🔥', 'votes': 638, 
#   'author_name': 'Namit Jain [INACTIVE]', 'author_link': 
#   '/Profile/18109487', 'data_date': '4/23/2021 6:17:25 AM'}, 
#   ...]

Retrieve Discuss Data

  • Import
from sololearnlib import Discuss
  • Create a class object.
dis = Discuss()
  • Using methods/functions
# Get posts available for discussion.
posts = dis.get_posts()
# [{'votes': '0', 'answers': '0', 'post_link': '/Discuss/2760604
#   /trying-to-pull-individual-values-from-a-dataframe-but-pulls-
#   arrays-instead', 'title': 'Trying to pull individual values 
#    from a dataframe but pulls arrays instead', 'tags': [...],
#   'author_name': 'Hernando Abella', 'author_link': '/Profile
#   /1478871/', 'data_date': '4/20/2021 4:12:36 PM', 
#   'avatar_link': 'https://blob.sololearn.com/avatars/e97c267a-
#    e433-4c47-81f3-6d32dcd30570.jpg'}, ...]

# Trending topics on discussions.
hot_discuss = dis.get_hot_today()
# [{'Can we obtain graphs in node code here at sololearn ?': 
#   '/Discuss/2784363/can-we-obtain-graphs-in-node-code-here-at-
#   sololearn/'}, {'Why R code is necessary?': '/Discuss/2784479
#   /why-r-code-is-necessary/'}, ...]

Retrieve Top Learners Data

  • Import
from sololearnlib import TopLearners
  • Create a class object.
top = TopLearners()
  • After creating an object you can use some of its attributes.
print(top.courses)
# {'c': {'link': '/Leaderboard/C', 'title': 'C Tutorial'}, ...}

print(top.leaderboard_title)
# 'Global Leaderboard'
  • Using methods/functions
# List of user who top the 'react' leaderboard.
board = top.get_leaderboard("react")
# {'1': {'name': 'Arthur', 'points': 2000}, '2': {'name': 
#  'Accountz5', 'points': 794}, '3': {'name': 'Hayk Tester1', 
#  'points': 760}, ...}

Development

Want to contribute? Great!

Head toward the github repository:

Todos

  • Write MORE Tests.

  • Add error handling.

  • Make retrieval time faster.

License


MIT

Free Software, Hell Yeah!

Metadata

Release files for sololearnlib 4.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sololearnlib 4.0.3
File Size Uploaded
sololearnlib-4.0.3.tar.gz 8.9 kB Details

Release files / sololearnlib-4.0.3.tar.gz

Download URL sololearnlib-4.0.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
695038ef6d7c9f5333d3ddd193eea3d562c3b0b9883e89ca9ee82decbcdd2069
BLAKE2b-256 checksum
How to use checksums
d5ba4b1e0dc388f383dc91c899f8d6009920a17abf673817468847726a675b50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

4.0.3 This release

1 release file

4.0.2

1 release file

4.0.1

1 release file

4.0.0

1 release file

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page