Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Fri Jul 28 12:04:34 2017
  5.  
  6. @author: darcnos
  7. """
  8.  
  9. import requests, json
  10.  
  11. def login():
  12. global siteurl
  13. siteurl = input('https://')
  14. #siteurl = 'https://webdocs.fileboundrs.com'
  15. #print(siteurl)
  16. #u = 'dcarson'
  17. #p = 'yoursecretpassword'
  18. u = input('Username: ')
  19. p = input('Password: ')
  20. data = {
  21. 'username': u,
  22. 'password': p
  23. }
  24.  
  25. login = 'https://applications.filebound.com/v3/login/?fbsite={}'.format(siteurl)
  26. try:
  27. r = requests.post(login, data)
  28. guid = r.json()
  29. return guid
  30. except requests.exceptions.Timeout:
  31. print('Connection timed out. Please try again.')
  32. except requests.exceptions.TooManyRedirects:
  33. print('Too many redirects. Check your URL and try again.')
  34. except requests.exceptions.RequestException as e:
  35. print('Catastrophic error. Bailing.')
  36. print(e)
  37. sys.exit(1)
  38.  
  39.  
  40. guid = login()
  41. print(siteurl)
  42.  
  43. sitenums = ['018', '019', '020']
  44. for i in range(len(sitenums)):
  45. qstring = 'https://applications.filebound.com/v3/query/projectId_1/F4_{}/all?fbsite=https://{}&guid={}'.format(i, siteurl, guid)
  46. print(qstring)
  47. r = requests.get(qstring)
  48. if r.status_code == 200:
  49. with open('output.txt', 'w') as text_file:
  50. json_object = r.json()
  51. for file in json_object[0]['files']['Collection']:
  52. print('fug')
  53. #rint(json_object[0]['files']['Collection'][i]['documentCount'], file=text_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement