-
-
Save tupaschoal/4f7c3ce3a7b52f1ab2903da8b76f575f to your computer and use it in GitHub Desktop.
Script created to attempt to programatically navigate Skoob fetching a user's bookshelf and the gender distribution of the books they have read
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import requests | |
| SKOOB_URL = "https://www.skoob.com.br" | |
| SKOOB_LOGIN_URL = f"{SKOOB_URL}/login" | |
| SKOOB_BOOKSHELF = f"{SKOOB_URL}/estante/livros/todos" | |
| def login_skoob(email, senha): | |
| """Logins into Skoob manually and returns the session and user_id""" | |
| payload = {'data[Usuario][email]': email, | |
| 'data[Usuario][senha]': senha} | |
| session = requests.Session() | |
| session_request = session.post(SKOOB_LOGIN_URL, data=payload) | |
| user_re = re.search(r'/usuario/(\d+)', session_request.text) | |
| user_id = user_re.group(1) if user_re else None | |
| if not user_id: | |
| raise Exception("Could not login to skoob, exiting") | |
| return (session, user_id) | |
| session, user_id = login_skoob("", "") | |
| bookshelf_page = session.get(f"{SKOOB_BOOKSHELF}/{user_id}") | |
| print(bookshelf_page.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment