Skip to main content

Python wrapper for the CNX Archive API(http://archive.cnx.org)

Project description

A Python wrapper around the Archive web api.

Quick start

Instantiate the ArchiveClient:

client = ArchiveClient()

Get a collection:

collection = client.get_collection("7fccc9cf-9b71-44f6-800b-f9457fd64335")

You now have access to lots of information about the collection.

collection.title
>> "Chemistry 2e"
collection.version
>> "9.18"

If you need to access a subcollection or module you can explore collection.table_of_contents

toc = collection.table_of_contents
for item in toc.contents
    print(item)
>><Module [Preface]>
>><SubCollection [Essential Ideas]>
>><SubCollection [Atoms, Molecules, and Ions]>
>><SubCollection [Composition of Substances and Solutions]>

You can grab a module from the contents and get other information:

module = toc.contents[0]
print(module.title)
>>"Preface"
print(module.html_title)
>>"<span class="os-text">Preface</span>"

If you want to print the json or the html version you can do that too

module = toc.contents[0]
print(module.title)
>>"Preface"
module_html = module.get_html()
print(module_html)
>><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="robots" content="noindex"/></head><body><div data-type="page" id="138634ed-6ed0-4edb-b13d-b78d388028b0" class="preface" ...

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

archive-api-client-0.0.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page