edgi-govdata-archiving / wayback

A Python API to the Internet Archive Wayback Machine
https://wayback.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
61 stars 12 forks source link

Add top-level convenience functions #149

Open Mr0grog opened 8 months ago

Mr0grog commented 8 months ago

Today, you have to create a WaybackClient instance in order to do anything with this library. We should add convenience functions that mirror the search() and get_memento() methods on clients (and whatever other methods might be added to WaybackClient in the future) so you can just call methods without needing to instantiate a client or session:

from datetime import datetime
import wayback

wayback.get_memento('https://nasa.gov/', datetime(2016, 12, 31))

I think these would use ideally use some sort of shared client or session under the hood rather than each call creating and destroying a whole client, although that might cause some issues with leaving some connections open/hanging — needs investigation.

Depends on getting thread safety first in #58.