Skip to main content

scrape-goodreads

Python package to scrape data from goodreads.com website. Authors, Books, and Quotes can be extracted.

Project made during a Deep Learning project for poem generation using GPT2 model.

Installation

Install scrapereads package from PyPi:

pip install scrapereads

Or from GitHub:

git clone https://github.com/arthurdjn/scrape-goodreads
cd scrape-goodreads
pip install .

Getting Started

GoodReads API

You can search for Author, Book or Quote from the API:

from scrapereads import GoodReads

# Connect to the API
goodreads = GoodReads()

# Search for an author, from it's ID.
AUTHOR_ID = 3389
author = goodreads.search_author(AUTHOR_ID)
# Search for a book
BOOK_ID = 3048970
book = goodreads.search_book(AUTHOR_ID, BOOK_ID)
# Look for the 10 first books (set it to ``top_k=None`` to turn it off)
books = goodreads.search_books(AUTHOR_ID, top_k=10)
# ...Or quotes
quotes = goodreads.search_quotes(AUTHOR_ID, top_k=5)

Quotes are made of a text, but optional information can be added (like number of likes, tags, reference etc.)

quotes = goodreads.search_quotes(AUTHOR_ID, top_k=5)

for quote in quotes:
    print(quote)
    print()

Output:

"Books are a uniquely portable magic."
- Stephen King, from "On Writing: A Memoir Of The Craft"
  Likes: 16225, Tags: books, magic, reading

"If you don't have time to read, you don't have the time (or the tools) to write. Simple as that."
- Stephen King
  Likes: 12565, Tags: reading, writing

"Get busy living or get busy dying."
- Stephen King, from "Different Seasons"
  Likes: 9014, Tags: life

"Books are the perfect entertainment: no commercials, no batteries, hours of enjoyment for each dollar spent. What I wonder is why everybody doesn't carry a book around for those inevitable dead spots in life."
- Stephen King
  Likes: 8667, Tags: books

"When his life was ruined, his family killed, his farm destroyed, Job knelt down on the ground and yelled up to the heavens, "Why god? Why me?" and the thundering voice of God answered, There's just something about you that pisses me off."
- Stephen King, from "Storm Of The Century"
  Likes: 7686, Tags: god, humor, religion

Structure

The package is divided as follows:

  • Author
  • Book, inherits from Author
  • Quote, inherits from Book

Retrieve data

Once you have one of these objects, you can also access data directly through their methods:

author = goodreads.search_author(AUTHOR_ID)
books = author.get_books()
quotes = author.get_quotes()

# Idem from an book
book = goodreads.search_book(AUTHOR_ID, BOOK_ID)
quotes = book.get_quotes()

In addition, you can retrieve parent objects from children:

author = goodreads.search_author(AUTHOR_ID)
quotes = author.get_quotes(top_k=10)
quote = quotes[0]

# Access to parent classes
book = quote.get_book()
author = quote.get_author()

You can scrape for description, links and other details information:

author = goodreads.search_author(AUTHOR_ID)
info = author.get_info()  # description of the author (genre, description, references etc.)

You can finally retrieve similar authors from an author with:

author = goodreads.search_author(AUTHOR_ID)
authors = author.get_similar_authors(top_k=5)

Save and export

You can save data in a JSON format (and encode it to ASCII if you want).

author = goodreads.search_author(AUTHOR_ID)
author_data = author.to_json(encode='ascii')
# Idem for book and quote

Metadata

Release files for scrapereads 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapereads 0.0.2
File Size Uploaded Provenance
scrapereads-0.0.2.tar.gz 226.3 kB Without provenance Details

Release files / scrapereads-0.0.2.tar.gz

Download URL scrapereads-0.0.2.tar.gz
Size 226.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9233789299a4af46c0e89c664f07e1995ef7418eae458ca14bb1bd1e5249bf0c
BLAKE2b-256 checksum
How to use checksums
66e1e6ccd94b72461345ac8010d7a363aa19f6af114e67b3635f2702b0c21d70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

Security for scrapereads 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page