Search Ocean of PDF, browse an author's catalog, and download epubs.
python3 -m pip install -r requirements.txtWalks https://oceanofpdf.com/?s=<query> and follow-on pages until a page returns no results. Filters out non-English entries by default (entries with no language declared are kept).
python3 search.py "My Husband's Wife"
python3 search.py "My Husband's Wife" --language english
python3 search.py "My Husband's Wife" --download ./booksProgrammatic use:
from search import search
results = search("My Husband's Wife") # english only
results = search("My Husband's Wife", language=None) # no filter
results = search("My Husband's Wife", download_to="./books") # also downloads every hitEach result is a dict: title, href, date, author, language, genre (author, language, and genre are not required).
Same parsing as search, but walks https://oceanofpdf.com/category/authors/<slug>/page/N/.
python3 author.py "Alice Feeney"
python3 author.py "Alice Feeney" --download ./booksfrom author import by_author
results = by_author("Alice Feeney")
results = by_author("Alice Feeney", download_to="./books") # grab the whole catalogTakes one or more book page URLs (the href from a search/author result, e.g. https://oceanofpdf.com/authors/alice-feeney/pdf-epub-my-husbands-wife-download/), finds the epub form on each page, posts it to Fetching_Resource.php, follows the meta-refresh to the CDN, and writes the file to disk.
Two filters are applied:
- Pre-download: any URL without
epubin its path is skipped (PDF-only listing). - Post-download: each saved epub is opened and its
dc:languagetag is checked. Files whose language doesn't contain the requested code are deleted. Default is"en"(matchesen,en-US,en-UK,eng, …). Files missing a language tag are kept. Passlanguage=Noneto disable.
python3 downloader.py <destination_dir> <book_url> [<book_url> ...]Programmatic use:
from downloader import download, download_many, epub_language
path = download(book_url, "/path/to/dir") # one book, returns saved path
results = download_many(urls, "/path/to/dir") # default lang='en'
results = download_many(urls, "/path/to/dir", language="es")
results = download_many(urls, "/path/to/dir", language=None) # no language check
lang = epub_language("/path/to/file.epub") # 'en', 'en-US', None, ...Errors during a download_many run don't abort the batch — they're logged per-URL and recorded in the returned (url, path, error) tuples.
parse_page, paginate, filter_language, print_results. Used by search.py and author.py.
Walks a folder and prints each epub's dc:language value. Useful for spot-checking a directory of downloads.
python3 check_languages.py # defaults to ./Books
python3 check_languages.py ./somedir- Call
search(...)orby_author(...)to get candidates. - Either pick specific
hrefs and pass them todownload_many(...), or passdownload_to=<dir>to grab every result in one shot.
Inspired by https://github.com/Krishna-Sivakumar/opdf-scraper