csvApiParser
Python parser to combine API and CSV results
https://github.com/piotrr79/csvApiParser
import requests
import json
class ApiData:
""" Api parser """
def __init__(self):
self
def getUrlData(self, url):
""" Get data from api
Args:
self: Self.
url: Api url
Returns:
Http resource content
"""
try:
return requests.get(url)
except Exception as err:
return str(err)
def getContent(self, url):
""" Parse data from api channel
Args:
self: Self.
url: Api url
Returns:
Json content
"""
data = self.getUrlData(url)
if data.status_code == 200:
return data.json()
else:
raise Exception('Api did not return valid response')
Python parser to combine API and CSV results. To install and run follow GitHub Readme file.
Sample API mock server included. To use it from project directory run
python3 server/apiMock.py
This will run simple Flask server with two api channels, one for success response with sample api data under /api-success and another one for 404 response under /