A package for scraping and serving book data.
Project description
bookspointer
A package for scraping and serving book data.
Installation
pip install bookspointer
Usage
Import and use the modules in your Python code:
from bookspointer.scraper import BookScraper
from bookspointer.server import BookAPI, AuthorAPI
from bookspointer.sheet import AuthorSheetManager
from rich import print
# Initialize the main classes
scraper = BookScraper([5, 17]) # Categories to scrape by single page
book_api = BookAPI()
author_api = AuthorAPI()
def update_authors_from_bookspointer():
# Fetch and update authors from Google Sheet to your server
author_sheet = AuthorSheetManager().run()
def update_books_from_authors():
# Fetch unscraped authors and update their books
authors = author_api.get_unscraped_authors()
for author in authors:
author_url = author.get('author_link')
author_name = author.get('author_name', 'Unknown')
author_id = author.get('author_id')
if not author_url:
continue
books = scraper.get_book_list(author_url)
for book in books:
book_list = scraper.get_book_details(book, author_id)
for book in book_list:
add_book = book_api.create(book)
author_api.update(author.get('id'), {"is_scraped": "yes"})
print(f"Added book: {book['title']} by {author_name} with ID: {add_book}")
print(f"Finished scraping books for author: {author_name}")
def main():
print("Starting to update authors from Bookspointer...")
update_authors_from_bookspointer()
print("Authors updated successfully.")
print("Starting to update books from authors...")
update_books_from_authors()
print("Books updated successfully.")
if __name__ == "__main__":
main()
Features
- Scrape book data
- Serve book data via API
- Sync authors and books with Google Sheets
Project Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bookspointer-0.1.5.tar.gz
(15.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bookspointer-0.1.5.tar.gz.
File metadata
- Download URL: bookspointer-0.1.5.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d97034b409d2ba4a9f924b087dca7da09809a92b66bbf5fd55d012b64474e81
|
|
| MD5 |
abd3c70a2844a75cf392884d6f3b4d01
|
|
| BLAKE2b-256 |
2965b026bf6644779541612211811fd64592b836dc976cf7e9bf9e962368538a
|
File details
Details for the file bookspointer-0.1.5-py3-none-any.whl.
File metadata
- Download URL: bookspointer-0.1.5-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3604573fcd1f4109b1bd1cd6b24b7197cce05431f0ab1da5f77ff81e75d3b18a
|
|
| MD5 |
f07d52f584533850cd8f9fb7ce301ee5
|
|
| BLAKE2b-256 |
8f0f037ad5dbcf1071505f31773e1d1e4d8282a5d3467324b1ecf0be9c8446d5
|