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 StatusTests

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for scrapxd-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9efd0b9dca1f3178fcb8928d8f917eee60ff16ab81ebb2b4c3ee400c0130e627
MD5 11f432ad4d1016b00a0861771aded9d2
BLAKE2b-256 90990d2c6627e482a701120fdd9342993ebf3f2604c6f78c59418debdad3fcb3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scrapxd-0.1.3-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.11.14

File hashes

Hashes for scrapxd-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4cd58e4edc0a2a2441d4fa568957152fb764b8d4cd1be701c90d38300410aedd
MD5 cd78a6a0b9a615307fde1ef720b00710
BLAKE2b-256 74740f8ee38af6c9cd6341d9e59d87371f6c99c9f17630bea72a66817638e688

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