Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. import requests
  2. import json
  3. import datetime
  4. import time
  5.  
  6.  
  7. def convert(dt):
  8.     return str(time.mktime(datetime.datetime.strptime(dt, "%Y-%m-%d %H:%M:%S").timetuple()))
  9.  
  10.  
  11. class Incedents:
  12.  
  13.     def __init__(self):
  14.         self.link = 'https://bikewise.org:443/api/v2/incidents'
  15.  
  16.     def parse(self, occurred_before, occurred_after):
  17.         parameters = {'occurred_before': convert(occurred_before), 'occurred_after': convert(occurred_after)}
  18.         r = requests.get(self.link, params=parameters).text
  19.  
  20.         response_get = json.loads(r)
  21.  
  22.         for item in response_get['incidents']:
  23.             id = item['id']
  24.             title = item['title']
  25.             print('id={}'.format(id) + ' - ' + 'title={}'.format(title))
  26.  
  27.  
  28. incedents = Incedents()
  29. incedents.parse('2019-09-10 12:00:00', '2019-09-10 23:59:59')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement