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.
-
Get courses info and lessons data.
-
Retrieve 'Hot Today' discussions.
-
Find out what are the trending, most recent and unanswered discussions.
Tech
sololearnlib just uses bs4 (BeautifulSoup4).
Installation
sololearnlib requires Python 3 v3.5+ to run.
$ pip install sololearnlib
Usage
Retrieve Blog data
- Import
from sololearnlib.sololearn import Blog
- Create a class object.
blog = Blog()
- After creating an object you can use some of its attributes.
print(blog.domain)
# "https://www.sololearn.com"
- Using methods/functions
articles = blog.get_articles()
# [{'article_link': '/Blog/73/habit-formi...-learning/', 'content': ' \xa0For most of us, th...ss time.\xa0 ', 'date': '07 August 2020', 'image_link': 'https://api.sololear...ning_1.jpg', 'title': 'Habit-Forming Learni...d Learning'}, ...]
# Get the link of first article.
article_link = articles[0]["article_link"]
# '/Blog/73/habit-forming-learning-vs-forced-learning/'
full_text = blog.get_full_article(article_link)
# '\n\nDo you struggle when learning new things? Most people do -- even when receiving a formal education in school or attending college, it can be hard to make new concepts stick. ...'
Retrieve Code Playground Data
- Import
from sololearnlib.sololearn import CodePlayground
- Create a class object.
ground = CodePlayground()
- After creating an object you can use some of its attributes.
print(ground.hot_today)
# [{'Web Dev Quiz': 'https://code.sololea...zpmPj7kP/#'}, ...]
- Using methods/functions
codes = ground.get_codes()
# [{'author_link': '/Profile/12942084', 'author_name': 'Aakaanksha 💕', 'code_link': 'https://code.sololea...oj07HPmq/#', 'code_name': 'Google Clone or Real? 😳💕', 'data_date': '8/9/2020 7:36:06 AM', 'votes': 1146}, ...]
Retrieve Courses Data
- Import
from sololearnlib.sololearn import Courses
- Create a class object.
courses = Courses()
- After creating an object you can use some of its attributes.
print(courses.courses)
# {'c': {'counts': {...}, 'description': '\nOur C tutorial cove...uch more.\n', 'icon': '/Icons/Courses/1089.png', 'link': '/Course/C/', 'title': 'C Tutorial'}, ...}
- Using methods/functions
lessons = courses.get_lessons("python")
# {'Basic Concepts': ['Welcome to Python', 'Your First Program', 'Simple Operations', 'Floats', 'Other Numerical Operations', 'Strings', 'String Operations', 'Variables', 'Taking User Input', ...], ...}
Retrieve Discuss Data
- Import
from sololearnlib.sololearn import Discuss
- Create a class object.
dis = Discuss()
- After creating an object you can use some of its attributes.
print(dis.hot_today)
# [{'[SOLVED]C++ Challenge problem': '/Discuss/2437254/sol...e-problem/'}, {'[Solved] Does Earnin...ves us XP?': '/Discuss/2437589/sol...ves-us-xp/'}, ...]
- Using methods/functions
posts = dis.get_posts()
# [{'answers': '24716', 'author_link': '/Profile/5056131/', 'author_name': 'benka', 'avatar_link': 'https://avatars.solo...b873e5.jpg', 'data_date': '7/6/2017 5:02:16 PM', 'post_link': '/Discuss/516185/мног...оговорящих', 'tags': [...], 'title': 'много ли тут нас, ру...говорящих?', 'votes': '1199'}, ...]
Retrieve Top Learners Data
- Import
from sololearnlib.sololearn 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)
# {'1': {'name': 'JΞΜΔ 🇨🇩👑', 'points': 1070064}, ...}
print(top.leaderboard_title)
# 'Global Leaderboard'
- Using methods/functions
board = top.get_leaderboard("python")
# {'1': {'name': '👑 Prometheus 🇸🇬', 'points': 193985}, ...}
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
Built Distribution
Hashes for sololearnlib-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | becc1e4b008ec3df2cfce81e61415c52a70a1a2b9f023b199b5a35bd607079cb |
|
MD5 | 4eab63b50dbbcd35e69de89d1b941150 |
|
BLAKE2b-256 | 59b4569f2b4aa7ec8ff15280ec0620a87ae483935589c1dc5947aa4430b3e424 |