Newer
Older
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a WebarchivSession Object with convenience methods for easy access with your API-Key "
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from webarchiv import WebarchivSession\n",
"\n",
"w = WebarchivSession(apikey)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Submit a URL search to get all archived capturedates of the requested URL"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"url = \"http://www.onb.ac.at\"\n",
"response = w.wayback_search(url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The search always returns the full response. Checking for status_code 200 before extracting the response is always a good idea"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"if response.status_code != 200:\n",
" print(\"Something went wrong ...\")\n",
" exit(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now it is safe to extract the response\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the total number of captures of the requested URL"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
]
}
],
"source": [
"print(response.json()['total'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the Archiveurl of the oldest Capuredate of the requested URL"
]
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://webarchiv.onb.ac.at/web/20090916183601/http://www.onb.ac.at\n"
]
}
],
"source": [
"\n",
"captureurl = 'https://webarchiv.onb.ac.at/web/' + capturedate + '/' + url\n",
"\n",
"print (captureurl)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",