Skip to content

Instantly share code, notes, and snippets.

@StefRe
Created December 8, 2020 12:20
Show Gist options
  • Save StefRe/b836241b758bf179304dc925e160a81a to your computer and use it in GitHub Desktop.
Save StefRe/b836241b758bf179304dc925e160a81a to your computer and use it in GitHub Desktop.
SLUB get availablilty status
import time
import asyncio
import aiohttp
async def get_status(session, id):
async with session.get(f"https://katalog.slub-dresden.de/id/{id}/?type=1369315139&tx_find_find%5Bdata-format%5D=json-holding-status&tx_find_find%5Bformat%5D=data") as response:
j = await response.json()
print(id, j["status"])
async def get_search_result():
async with aiohttp.ClientSession() as session:
async with session.get("https://katalog.slub-dresden.de/?type=1369315142&tx_find_find%5Bformat%5D=data&tx_find_find%5Bdata-format%5D=app&tx_find_find%5Bpage%5D=1&tx_find_find%5Bq%5D%5Btitle%5D=kotlin") as response:
j = await response.json()
await asyncio.gather(*[get_status(session, doc["id"]) for doc in j["docs"]])
start = time.perf_counter()
asyncio.get_event_loop().run_until_complete(get_search_result())
print(f"--> {time.perf_counter() - start:.1f} s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment