class feupy.Credentials(username=None, password: str = None, base_url: str = '')

This class represents your login credentials. It also features a non-persistent cache that stores htmls of urls previously accessed.

  • username (int or str, optional) – Your username. You will be prompted for your username if you don’t pass a username as an argument
  • password (str, optional) – Your password. You will be prompted for your password if you don’t pass a password as an argument
  • base_url (str, optional) – The url of the faculty (in english) (defaults to “”)

Your username (e.g. 201806185)

Type:int or str

A requests.Session object that holds the login cookies


A dictionary that maps a url string to an html string


The url of your faculty (in english) (defaults to “”)



from feupy import Credentials

username = 201806185
password = ""

creds = Credentials(username, password)

# You may instead enter your username and password at runtime
creds = Credentials()
# Username?
# :> up201806185
# Password for 201806185?
# :>
download(url: str, folder_path: str) → str

Downloads the file from the given url and saves it to the given folder path. If the path doesn’t exist, it will be created automatically.

  • url (str) – The url of the file to be downloaded
  • folder_path (str) – The path of the folder you want to download the file to

The path of the file as an str

get_html(url: str, params: dict = {}) → str

Functionally equivalent to requests.get(url, params).text, with scripts and styles removed. If the result is already in cache, the method will just return the value from the cache instead of making a web request.

  • url (str) – The url of the html to be fetched
  • params (dict, optional) – the query portion of the url, should you want to include a query

A string which is the html from the requested page url

get_html_async(urls, n_workers: int = 10)

Credentials.get_html(), but async, give or take.

Takes a list (or any iterable) of urls and returns a corresponding generator of htmls. The htmls have their scripts and styles removed and are stored in cache.

  • urls (iterable(str)) – The urls to be accessed
  • n_workers (int, optional) – The number of workers.

An str generator