Skip to content

Instantly share code, notes, and snippets.

@physikerwelt
Last active June 30, 2021 07:10
Show Gist options
  • Save physikerwelt/96edfb9b827209614c92c3e670428317 to your computer and use it in GitHub Desktop.
Save physikerwelt/96edfb9b827209614c92c3e670428317 to your computer and use it in GitHub Desktop.
python sickle minimal example
# run pip install sickle
from sickle import Sickle
import time
METADATA_PREFIX = 'oai_zb_preview'
METADATA_PREFIX = 'oai_dc'
URL = 'https://oai.zbmath.org/v1/'
def log(m):
print(m)
def run():
s = Sickle(URL, retry_status_codes=[429])
r = s.ListRecords(metadataPrefix=METADATA_PREFIX)
i = 0
t0 = time.time()
for row in r:
if i > 100000:
return
else:
i += 1
if i % 100:
current_time = time.time()
log(f"{i / (current_time - t0)} records per second")
if __name__ == '__main__':
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment