Skip to main content

A Python library for scraping, analysing and exporting Letterboxd data.

Project description

scrapxd: The Library for Letterboxd Data

PyPI Version Python Versions License: MIT Build Status

scrapxd is a Python library designed for web scraping, analyzing, and exporting data from Letterboxd, the social network for cinephiles. With an intuitive, strictly-typed API using Pydantic, scrapxd makes it easy to access user profiles, film lists, diaries, and much more.


Key Features

  • Scrape Whatever You Need: Extract detailed data from user profiles, including watched films, ratings, diary entries, lists, followers, and more.
  • Film Search: Search for films on Letterboxd based on various filters.
  • Pydantic Data Models: All returned data is validated and structured into Pydantic models, ensuring consistency and ease of use in your code.
  • Analytics Module: Perform statistical analysis on the collected data, such as correlations and trends (requires the [analytics] extra).
  • Exporting Module: Export collected data to popular formats like CSV, JSON, and Excel (.xlsx) (requires the [export] extra).
  • Retries Logic: Utilizes tenacity for automatic retries on network failures, making the scraping process more reliable.
  • Simple and Intuitive: Designed with a clean and easy-to-use API, as demonstrated in the examples.

Installation

You can install the library directly from PyPI.

Standard Installation:

Bash

pip install scrapxd

The library has optional dependencies for extra features. You can install them as needed:

For Data Analytics:

Bash

pip install "scrapxd[analytics]"

For File Exporting:

Bash

pip install "scrapxd[export]"

To Install Everything (including testing dependencies):

Bash

pip install "scrapxd[all]"

Quickstart

Using scrapxd is very simple. Here is a basic example to get a user's watched films:

Python

from scrapxd import Scrapxd

# 1. Create a client instance
client = Scrapxd()

# 2. Get data for a Letterboxd user
# The client handles searching and pagination automatically
user = client.get_user("your_username_here")
user_films = user.logs

# 3. Access the data
print(f"Total films watched by '{user_films.username}': {user_films.number_of_entries}")

# Each entry is a Pydantic object with structured data
for entry in user_films.entries[:5]: # Displaying the first 5
    print(f"- {entry.film.title} ({entry.film.year}) - Rating: {entry.rating}")

# 4. (Optional) Export the data to an Excel file
try:
    user_films.to_xlsx(f"{user_films.username}_films")
    print(f"\nData exported to {user_films.username}_films.xlsx")
except ImportError:
    print("\nTo export data, please install with: pip install \"scrapxd[export]\"")

Detailed Examples

For a more in-depth guide covering all features like profile analysis, comparisons, and advanced use cases, please explore the Jupyter notebooks in the /examples folder:


Contributing

Contributions are very welcome! If you have an idea for a new feature, find a bug, or want to improve the documentation, please open an Issue or submit a Pull Request.


License

This project is licensed under the MIT License. See the LICENSE file for more details.


Contact

Cauã Santos - My LinkedIn Profile - cauafsantosdev@gmail.com

GitHub URL: https://github.com/cauafsantosdev/scrapxd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrapxd-0.1.0.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrapxd-0.1.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file scrapxd-0.1.0.tar.gz.

File metadata

  • Download URL: scrapxd-0.1.0.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scrapxd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9da7cb021ada098fd50b5ef172c9eb692f5beaa994ddaae4268870eacb6a760
MD5 1e8159beb3329f8df4f757e53c9acb44
BLAKE2b-256 68741695145d098c6b2c0562b60cda6497a72a9e53bb4f63efb2d617bdd03ae1

See more details on using hashes here.

File details

Details for the file scrapxd-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scrapxd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scrapxd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 369c4de6f75bfcf43f5f7378740bbf27688c75222c37dddb70ef693ff5603a13
MD5 0435c40a859a1785f31a380b084a9418
BLAKE2b-256 5d1db31a014ffd91caa118158856770268383b80d46b7b9688bbab1455652d34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page