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.2.tar.gz (44.5 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.2-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scrapxd-0.1.2.tar.gz
  • Upload date:
  • Size: 44.5 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.2.tar.gz
Algorithm Hash digest
SHA256 294e72ba7c9374309265e485e91c02405300706b8413b1563a61b51b3118b533
MD5 296f8dc6e2caf6327dfdb25010379c50
BLAKE2b-256 fcda444d4aa747e16a2c9cecf6742e161a7e0fc9e3bad5c8ca12e5a4a3f42863

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scrapxd-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 405805758392098cee5430eef9c5967e7287cc096c40518acebef826a12484b2
MD5 2853bf81d36f0ee1ab80254a5617ffaa
BLAKE2b-256 e80befbdb9aec9d1930d93799d4fe801b63a69de2d375a772c9ae753ba731935

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