Kusari

ArXiver

Jul 19th, 2019 (edited)
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Saves ArXiv papers locally in the directory in which the script is run in. Intended to run on GNU/Linux but should work on any system
  2. import shutil, requests, time
  3. from random import randint
  4.  
  5. while True:
  6.     try:
  7.         r0 = randint(10, 20)
  8.         r1 = randint(1, 9)
  9.         r2 = randint(1000, 9999)
  10.         url = "https://arxiv.org/pdf/" + str(r0) + "0" + str(r1) + ".0" + str(r2) + ".pdf"
  11.         response = requests.get(url, stream=True)
  12.         with open(str(r0) + '0' + str(r1) + '.0' + str(r2) + '.pdf', 'wb') as out_file:
  13.             shutil.copyfileobj(response.raw, out_file)
  14.         del response
  15.     except:
  16.         time.sleep(5) # Prevent ratelimiting
RAW Paste Data