Retrieve public data from 'sololearn.com'.
Project description
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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sololearnlib-4.0.3.tar.gz
(8.9 kB
view details)
File details
Details for the file sololearnlib-4.0.3.tar.gz
.
File metadata
- Download URL: sololearnlib-4.0.3.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695038ef6d7c9f5333d3ddd193eea3d562c3b0b9883e89ca9ee82decbcdd2069 |
|
MD5 | 47f0eb096b4a9ef983ac9c2d0176ade1 |
|
BLAKE2b-256 | d5ba4b1e0dc388f383dc91c899f8d6009920a17abf673817468847726a675b50 |