G2 Templates updates, Ntoes for WilliamSonoma,Glassdoor, AchieveCE. Script updates.
This commit is contained in:
@ -16,3 +16,4 @@ TERMINUS_EMPLOYEE = "M2er8m0DMQyCyP7zOg3Gbae9k"
|
||||
BIGIDEAS = "mgGWRtmhebC9xulTXeSohVtop"
|
||||
ZENJOB = "LIXqtHXEqcXHyN0EtezngnpzA"
|
||||
DATASNIPPER = "098Odf9CIkk4aQA1lW7tsa9k8"
|
||||
CHUBB = "m6ZEBesXzpWx2vmp11rEHxrMY"
|
||||
|
||||
Binary file not shown.
@ -1,23 +1,34 @@
|
||||
import pprint
|
||||
import requests
|
||||
import pandas as pd
|
||||
import Apikeys
|
||||
|
||||
apiKey = "VNDXh8K4tLYJ-Nvp78bo6w"
|
||||
url = "https://api.northpass.com/v1/media"
|
||||
APIKEY = Apikeys.CHUBB
|
||||
URL = "https://api.northpass.com/v1/media"
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
|
||||
def getMedia(apiKey, url):
|
||||
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||
response = requests.get(url, headers=headers)
|
||||
json = response.json()
|
||||
print(json)
|
||||
toCsv(json)
|
||||
def getMedia(APIKEY, URL):
|
||||
list_data = []
|
||||
headers = {"accept": "application/json", "X-Api-Key": APIKEY}
|
||||
URL = f"{URL}?limit=100"
|
||||
response = requests.get(URL, headers=headers)
|
||||
datas = response.json()
|
||||
|
||||
for data in datas["data"]:
|
||||
file_type = data["attributes"]["file_type"]
|
||||
id_val = data["id"]
|
||||
create_link = data["links"]["create_course_from_file"]
|
||||
if "scorm" in file_type:
|
||||
data_tuple = (id_val, file_type, create_link)
|
||||
list_data.append(data_tuple)
|
||||
pp.pprint(list_data)
|
||||
print(len(list_data))
|
||||
|
||||
def toCsv(json):
|
||||
js = pd.json_normalize(json, "data", ["data"])
|
||||
# csv = pd.Series(js)
|
||||
js.to_csv("/Users/normrasmussen/Documents/Northpass/Scripts/API_Tests/spsmedia3.csv")
|
||||
# def toCsv(json):
|
||||
# js = pd.json_normalize(json, "data", ["data"])
|
||||
# # csv = pd.Series(js)
|
||||
# js.to_csv("/Users/normrasmussen/Documents/Northpass/Scripts/API_Tests/spsmedia3.csv")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
getMedia(apiKey, url)
|
||||
getMedia(APIKEY, URL)
|
||||
|
||||
Reference in New Issue
Block a user