Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import requests,json
  2. #Original URL for reference
  3. #url = "https://cdm22007.contentdm.oclc.org/digital/api/collections/p22007coll9/items/491899/false"
  4.  
  5.  
  6. page_count = 512;
  7.  
  8. url_prefix = "https://cdm22007.contentdm.oclc.org/digital/api/collections/p22007coll9/items/"
  9. url_page_count = 491899;
  10. url_suffix = "/false"
  11.  
  12. urls = []
  13.  
  14. #Construct a list of urls that will serve as a work queue
  15. for i in range(page_count):
  16.     # construct a url from the prefix, incremented page counter and suffix
  17.     #and store it in the list of urls
  18.     urls.append(url_prefix+ str(url_page_count+1)+url_suffix)
  19.     url_page_count += 1
  20.     #print(urls[i])
  21.  
  22.  
  23.  
  24. for j in range(len(urls)):
  25.     r = requests.get(url = urls[j])
  26.     json_data = json.loads(r.text)
  27.     print(json_data['text'])
  28.     print("__________________________________")
  29.  
  30. #stuff for reference
  31. #r = requests.get(url = url)
  32. #json_data = json.loads(r.text)
  33. #print(json_data['text'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement