Skip to content

Instantly share code, notes, and snippets.

@tupaschoal
Created June 30, 2024 10:42
Show Gist options
  • Select an option

  • Save tupaschoal/4f7c3ce3a7b52f1ab2903da8b76f575f to your computer and use it in GitHub Desktop.

Select an option

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
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