Created
September 15, 2021 01:59
-
-
Save timothycarambat/db52c7b475edc0bdf0771e064874a2c5 to your computer and use it in GitHub Desktop.
Senate and House Stock watcher Python3 data listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, json, datetime | |
# This function will grab the data from house/senate stockwatcher and return an array | |
# of dictonary items that represent transactions | |
def fetch_data(): | |
response = requests.get("https://senate-stock-watcher-data.s3-us-west-2.amazonaws.com/aggregate/all_transactions.json") | |
# response = requests.get("https://house-stock-watcher-data.s3-us-west-2.amazonaws.com/data/all_transactions.json") | |
if response.status_code != 200: | |
print("request failed.") | |
return False | |
data = response.json() | |
data.sort(key = lambda x: datetime.datetime.strptime(x['disclosure_date'], '%m/%d/%Y'), reverse=True) | |
return data | |
print(fetch_data()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment