I'm using the Geocodio API to find congreessional district information for a given address. Here's my code:
from geocodio import GeocodioClient
import json
client = GeocodioClient('MY API KEY')
availible_offices = ['Congress', 'State Legislature']
# offices_dict = ['cd': "Congress",'stateleg': "State Legislature"]
location = str(client.geocode("100 Renaissance Center, Detroit, MI 48243",fields=["cd", "stateleg"]))
print(location)
json.loads(location)
Here's the json it prints:
{'input': {'address_components': {'number': '100', 'street': 'Renaissance', 'suffix': 'Ctr', 'formatted_street': 'Renaissance Ctr', 'city': 'Detroit', 'state': 'MI', 'zip': '48243', 'country': 'US'}, 'formatted_address': '100 Renaissance Ctr, Detroit, MI 48243'}, 'results': [{'address_components': {'number': '100', 'street': 'Renaissance', 'suffix': 'Ctr', 'formatted_street': 'Renaissance Ctr', 'city': 'Detroit', 'county': 'Wayne County', 'state': 'MI', 'zip': '48243', 'country': 'US'}, 'formatted_address': '100 Renaissance Ctr, Detroit, MI 48243', 'location': {'lat': 42.329033, 'lng': -83.039762}, 'accuracy': 1, 'accuracy_type': 'rooftop', 'source': 'Semcog', 'fields': {'congressional_districts': [{'name': 'Congressional District 14', 'district_number': 14, 'congress_number': '117th', 'congress_years': '2021-2023', 'proportion': 1, 'current_legislators': [{'type': 'representative', 'bio': {'last_name': 'Lawrence', 'first_name': 'Brenda', 'birthday': '1954-10-18', 'gender': 'F', 'party': 'Democrat'}, 'contact': {'url': 'https://lawrence.house.gov', 'address': '2463 Rayburn House Office Building Washington DC 20515-2214', 'phone': '202-225-5802', 'contact_form': None}, 'social': {'rss_url': None, 'twitter': 'RepLawrence', 'facebook': '395759603917487', 'youtube': None, 'youtube_id': 'UCf0USy9GNigkB8O9sS1dodw'}, 'references': {'bioguide_id': 'L000581', 'thomas_id': '02252', 'opensecrets_id': 'N00034068', 'lis_id': None, 'cspan_id': '79924', 'govtrack_id': '412638', 'votesmart_id': '78851', 'ballotpedia_id': 'Brenda Lawrence (Michigan)', 'washington_post_id': None, 'icpsr_id': '21530', 'wikipedia_id': 'Brenda Lawrence'}, 'source': 'Legislator data is originally collected and aggregated by https://github.com/unitedstates/'}, {'type': 'senator', 'bio': {'last_name': 'Stabenow', 'first_name': 'Debbie', 'birthday': '1950-04-29', 'gender': 'F', 'party': 'Democrat'}, 'contact': {'url': 'https://www.stabenow.senate.gov', 'address': '731 Hart Senate Office Building Washington DC 20510', 'phone': '202-224-4822', 'contact_form': 'https://www.stabenow.senate.gov/contact'}, 'social': {'rss_url': 'http://stabenow.senate.gov/rss/?p=news', 'twitter': 'SenStabenow', 'facebook': 'SenatorStabenow', 'youtube': 'senatorstabenow', 'youtube_id': 'UCFoDKCvxSwCUfDv-4Eg4K5A'}, 'references': {'bioguide_id': 'S000770', 'thomas_id': '01531', 'opensecrets_id': 'N00004118', 'lis_id': 'S284', 'cspan_id': '45451', 'govtrack_id': '300093', 'votesmart_id': '515', 'ballotpedia_id': 'Debbie Stabenow', 'washington_post_id': None, 'icpsr_id': '29732', 'wikipedia_id': 'Debbie Stabenow'}, 'source': 'Legislator data is originally collected and aggregated by https://github.com/unitedstates/'}, {'type': 'senator', 'bio': {'last_name': 'Peters', 'first_name': 'Gary', 'birthday': '1958-12-01', 'gender': 'M', 'party': 'Democrat'}, 'contact': {'url': 'https://www.peters.senate.gov', 'address': '724 Hart Senate Office Building Washington DC 20510', 'phone': '202-224-6221', 'contact_form': 'https://www.peters.senate.gov/contact/email-gary'}, 'social': {'rss_url': None, 'twitter': 'SenGaryPeters', 'facebook': 'SenGaryPeters', 'youtube': 'RepGaryPeters', 'youtube_id': 'UC7LYNbnKSK2VZqQ98YROWHQ'}, 'references': {'bioguide_id': 'P000595', 'thomas_id': '01929', 'opensecrets_id': 'N00029277', 'lis_id': 'S380', 'cspan_id': '50199', 'govtrack_id': '412305', 'votesmart_id': '8749', 'ballotpedia_id': 'Gary Peters', 'washington_post_id': None, 'icpsr_id': '20923', 'wikipedia_id': 'Gary Peters'}, 'source': 'Legislator data is originally collected and aggregated by https://github.com/unitedstates/'}]}], 'state_legislative_districts': {'house': {'name': 'State House District 6', 'district_number': '6', 'is_upcoming_state_legislative_district': False}, 'senate': {'name': 'State Senate District 1', 'district_number': '1', 'is_upcoming_state_legislative_district': False}}}}]}
Here's the error that I get:
Traceback (most recent call last):
File "/Users/aliallam/Desktop/APCSP/Create Task/Main.py", line 13, in <module>
json.loads(location)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
I want to extract certain parts of the json and print them. Why am I getting this error and how do I go about doing that?
Thanks in advance!
Use eval():
dataj = eval(location)
dataj.keys()
Output:
dict_keys(['input', 'results'])
Related
I am using Python and I am trying to access the result of function PlacesAPI where I can see supermarkets around me and create a dataframe with few parts of each dictionary inside the main dictionary using a for loop, however I am getting the same information for different rows.
Can you please help me to put each different parts of dictionary in a different row?
Here is my code and the result (now reproducible):
from herepy import PlacesApi
import pandas as pd
def dataframe():
a = {'items': [{'title': 'Marcos Francisco dos Santos Padaria e Mercearia',
'id': 'here:pds:place:07675crc-dfd72cbf57bd45cc9277ed8530ffd61b',
'ontologyId': 'here:cm:ontology:supermarket',
'resultType': 'place',
'address': {'label': 'Marcos Francisco dos Santos Padaria e Mercearia, Rua Oswero Carmo Vilaça, 33, Petrópolis - RJ, 25635-101, Brazil',
'countryCode': 'BRA',
'countryName': 'Brazil',
'stateCode': 'RJ',
'state': 'Rio de Janeiro',
'city': 'Petrópolis',
'district': 'Petrópolis',
'street': 'Rua Oswero Carmo Vilaça',
'postalCode': '25635-101',
'houseNumber': '33'},
'position': {'lat': -22.5315, 'lng': -43.16904},
'access': [{'lat': -22.5314, 'lng': -43.16914}],
'distance': 134,
'categories': [{'id': '600-6300-0066', 'name': 'Grocery', 'primary': True},
{'id': '600-6300-0244', 'name': 'Bakery & Baked Goods Store'}],
'contacts': [{'phone': [{'value': '+552422312493'}]}]},
{'title': 'Mr. Frango',
'id': 'here:pds:place:076jx7ps-7c214f50052f0c23c9e5422ebde7d3cd',
'ontologyId': 'here:cm:ontology:supermarket',
'resultType': 'place',
'address': {'label': 'Mr. Frango, Rua Teresa, Petrópolis - RJ, 25635-530, Brazil',
'countryCode': 'BRA',
'countryName': 'Brazil',
'stateCode': 'RJ',
'state': 'Rio de Janeiro',
'city': 'Petrópolis',
'district': 'Petrópolis',
'street': 'Rua Teresa',
'postalCode': '25635-530'},
'position': {'lat': -22.52924, 'lng': -43.17222},
'access': [{'lat': -22.52925, 'lng': -43.1722}],
'distance': 545,
'categories': [{'id': '600-6300-0066', 'name': 'Grocery', 'primary': True},
{'id': '600-6000-0061', 'name': 'Convenience Store'}],
'references': [{'supplier': {'id': 'core'}, 'id': '1159487213'}],
'contacts': [{'phone': [{'value': '+552422201010'},
{'value': '+552422315720', 'categories': [{'id': '600-6000-0061'}]}]}]},
{'title': 'Mercadinho Flor de Petrópolis',
'id': 'here:pds:place:07675crc-6b03dfbac65a45c0bfc52ab9a3f04556',
'ontologyId': 'here:cm:ontology:supermarket',
'resultType': 'place',
'address': {'label': 'Mercadinho Flor de Petrópolis, Rua Teresa, 2060, Petrópolis - RJ, 25635-530, Brazil',
'countryCode': 'BRA',
'countryName': 'Brazil',
'stateCode': 'RJ',
'state': 'Rio de Janeiro',
'city': 'Petrópolis',
'district': 'Petrópolis',
'street': 'Rua Teresa',
'postalCode': '25635-530',
'houseNumber': '2060'},
'position': {'lat': -22.52895, 'lng': -43.17233},
'access': [{'lat': -22.52895, 'lng': -43.17219}],
'distance': 574,
'categories': [{'id': '600-6300-0066',
'name': 'Grocery',
'primary': True}]}]}
value = []
address = []
latlong = []
teste = pd.DataFrame(columns = ['nome','endereco','rua','numero',
'cidade','estado','cep','lat','long','raio'])
teste['nome'] = []
teste['endereco'] = []
teste['rua'] = []
teste['numero'] =[]
teste['cidade'] = []
teste['estado'] = []
teste['cep'] = []
teste['lat'] = []
teste['long'] = []
teste['raio'] = []
g = pd.DataFrame.from_dict(a.values())
h =[]
for i in range(3):
v = g[i].values[0]
h = v.items()
for k, l in h:
value.append(l)
for c, d in value[4].items():
address.append(d)
for la, lo in value[5].items():
latlong.append(lo)
novo_concorrente = {'nome': value[0], 'endereco':address[0],
'rua':address[7], 'numero':address[9],
'cidade':address[5], 'estado':address[3],
'cep':address[8],'lat':latlong[0],
'long':latlong[1],'raio':value[7]}
teste = teste.append(novo_concorrente, ignore_index=True)
return teste
You should focus on your for loop. I would suggest you to create a dictionary for each row you want to define in your final DataFrame, and then create a list to append those dictionaries to.
In example:
rows = []
for item in a["items"]:
row = {
"Latitude": item["position"]["lat"],
"Postal code": item["address"]["postalCode"],
}
rows.append(row)
result = DataFrame(rows)
result
Hope it helps as a starting point.
I have the following as part of a function to extract some info from a json response (at the bottom you can find a portion of it), and is working fine. But......
venues_list=[]
url = 'https://api.foursquare.com/v2/venues/search?client_id={}&client_secret={}&ll={},{}&v={}&categoryId={}&radius={}&limit={}'.format(CLIENT_ID, CLIENT_SECRET, lat, lng, VERSION, search_categoryId, radius, LIMIT)
results = requests.get(url).json()["response"]['venues']
venues_list.append([(
v['name'],
v['location']['lat'],
v['location']['lng'],
v['categories'][0]['name'],
v['id']) for v in results])
To the mix of objects I'm retrieving from the json file, i want to add:
v['location']['postalCode']
But is not working. I get a KeyError: 'postalCode'
If I do:
v['location']['distance']
v['location']['country']
v['location']['formattedAddress']
It works. I get no error.
These don't work either:
v['location']['cc']
v['location']['city']
I get the same KeyError: 'cc' , KeyError: 'city'
Is there something I'm missing? Can you help me understand why it behaves this way?
[{'id': '4ad4c061f964a52099f720e3',
'name': 'Live Organic Food Bar',
'location': {'address': '264 Dupont Street',
'lat': 43.67505287052667,
'lng': -79.40671518307245,
'labeledLatLngs': [{'label': 'display',
'lat': 43.67505287052667,
'lng': -79.40671518307245}],
'distance': 273,
'postalCode': 'M5R 1V7',
'cc': 'CA',
'city': 'Toronto',
'state': 'ON',
'country': 'Canada',
'formattedAddress': ['264 Dupont Street', 'Toronto ON M5R 1V7', 'Canada']},
'categories': [{'id': '4bf58dd8d48988d1d3941735',
'name': 'Vegetarian / Vegan Restaurant',
'pluralName': 'Vegetarian / Vegan Restaurants',
'shortName': 'Vegetarian / Vegan',
'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/vegetarian_',
'suffix': '.png'},
'primary': True}],
'referralId': 'v-1591407049',
'hasPerk': False},
I have tried to find the answer but I could not find it
I am looking for the way to save in my computer a json file from python.
I call the API
configuration = api.Configuration()
configuration.api_key['X-XXXX-Application-ID'] = 'xxxxxxx'
configuration.api_key['X-XXX-Application-Key'] = 'xxxxxxxx1'
## List our parameters as search operators
opts= {
'title': 'Deutsche Bank',
'body': 'fraud',
'language': ['en'],
'published_at_start': 'NOW-7DAYS',
'published_at_end': 'NOW',
'per_page': 1,
'sort_by': 'relevance'
}
try:
## Make a call to the Stories endpoint for stories that meet the criteria of the search operators
api_response = api_instance.list_stories(**opts)
## Print the returned story
pp(api_response.stories)
except ApiException as e:
print('Exception when calling DefaultApi->list_stories: %s\n' % e)
I got the response like this
[{'author': {'avatar_url': None, 'id': 1688440, 'name': 'Pranav Nair'},
'body': 'The law firm will investigate whether the bank or its officials have '
'engaged in securities fraud or unlawful business practices. '
'Industries: Bank Referenced Companies: Deutsche Bank',
'categories': [{'confident': False,
'id': 'IAB11-5',
'level': 2,
'links': {'_self': 'https://,
'parent': 'https://'},
'score': 0.39,
'taxonomy': 'iab-qag'},
{'confident': False,
'id': 'IAB3-12',
'level': 2,
'links': {'_self': 'https://api/v1/classify/taxonomy/iab-qag/IAB3-12',
'score': 0.16,
'taxonomy': 'iab-qag'},
'clusters': [],
'entities': {'body': [{'indices': [[168, 180]],
'links': {'dbpedia': 'http://dbpedia.org/resource/Deutsche_Bank'},
'score': 1.0,
'text': 'Deutsche Bank',
'types': ['Bank',
'Organisation',
'Company',
'Banking',
'Agent']},
{'indices': [[80, 95]],
'links': {'dbpedia': 'http://dbpedia.org/resource/Securities_fraud'},
'score': 1.0,
'text': 'securities fraud',
'types': ['Practice', 'Company']},
'hashtags': ['#DeutscheBank', '#Bank', '#SecuritiesFraud'],
'id': 3004661328,
'keywords': ['Deutsche',
'behalf',
'Bank',
'firm',
'investors',
'Deutsche Bank',
'bank',
'fraud',
'unlawful'],
'language': 'en',
'links': {'canonical': None,
'coverages': '/coverages?story_id=3004661328',
'permalink': 'https://www.snl.com/interactivex/article.aspx?KPLT=7&id=58657069',
'related_stories': '/related_stories?story_id=3004661328'},
'media': [],
'paragraphs_count': 1,
'published_at': datetime.datetime(2020, 5, 19, 16, 8, 5, tzinfo=tzutc()),
'sentences_count': 2,
'sentiment': {'body': {'polarity': 'positive', 'score': 0.599704},
'title': {'polarity': 'neutral', 'score': 0.841333}},
'social_shares_count': {'facebook': [],
'google_plus': [],
'source': {'description': None,
'domain': 'snl.com',
'home_page_url': 'http://www.snl.com/',
'id': 8256,
'links_in_count': None,
'locations': [{'city': 'Charlottesville',
'country': 'US',
'state': 'Virginia'}],
'logo_url': None,
'name': 'SNL Financial',
'scopes': [{'city': None,
'country': 'US',
'level': 'national',
'state': None},
{'city': None,
'country': None,
'level': 'international',
'state': None}],
'title': None},
'summary': {'sentences': ['The law firm will investigate whether the bank or '
'its officials have engaged in securities fraud or '
'unlawful business practices.',
'Industries: Bank Referenced Companies: Deutsche '
'Bank']},
'title': "Law firm to investigate Deutsche Bank's US ops on behalf of "
'investors',
'translations': {'en': None},
'words_count': 26}]
In the documentation says "Stories you retrieve from the API are returned as JSON objects by default. These JSON story objects contain 22 top-level fields, whereas a full story object will contain 95 unique data points"
The class is a list. When I have tried to save json file I have the error "TypeError: Object of type Story is not JSON serializable".
How I can save a json file in my computer?
The response you got is not json, json uses double quotes, but here its single quotes. Copy paste your response in the following link to see the issues
http://json.parser.online.fr/.
If you change it like
[{"author": {"avatar_url": None, "id": 1688440, "name": "Pranav Nair"},
"body": "......
It will work, You can use python json module to do it
import json
json.loads(the_dict_got_from_response).
But it should be the duty of the API provider to, To make it working you can json load the result you got.
fork_fig = {'categories': [{'alias': 'burgers', 'title': 'Burgers'},
{'alias': 'sandwiches', 'title': 'Sandwiches'},
{'alias': 'salad', 'title': 'Salad'}],
'coordinates': {'latitude': 35.10871, 'longitude': -106.56739},
'display_phone': '(505) 881-5293',
'distance': 3571.724649307866,
'id': 'fork-and-fig-albuquerque',
'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/_-DpXKfS3jv6DyA47g6Fxg/o.jpg',
'is_closed': False,
'location': {'address1': '6904 Menaul Blvd NE',
'address2': 'Ste C',
'address3': '',
'city': 'Albuquerque',
'country': 'US',
'display_address': ['6904 Menaul Blvd NE', 'Ste C', 'Albuquerque, NM 87110'],
'state': 'NM',
'zip_code': '87110'},
'name': 'Fork & Fig',
'phone': '+15058815293',
'price': '$$',
'rating': 4.5,
'review_count': 604}
frontier_restaurant = {'categories': [{'alias': 'mexican', 'title': 'Mexican'},
{'alias': 'diners', 'title': 'Diners'},
{'alias': 'tradamerican', 'title': 'American (Traditional)'}],
'coordinates': {'latitude': 35.0808088832532, 'longitude': -106.619402244687},
'display_phone': '(505) 266-0550',
'distance': 4033.6583235266075,
'id': 'frontier-restaurant-albuquerque-2',
'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/M9L2z6-G0NobuDJ6YTh6VA/o.jpg',
'is_closed': True,
'location': {'address1': '2400 Central Ave SE',
'address2': '',
'address3': '',
'city': 'Albuquerque',
'country': 'US',
'display_address': ['2400 Central Ave SE', 'Albuquerque, NM 87106'],
'state': 'NM',
'zip_code': '87106'},
'name': 'Frontier Restaurant',
'phone': '+15052660550',
'price': '$',
'rating': 4.0,
'review_count': 1369}
I have two restaurant list as above and i want to make function that returns a list of only the restaurants that are not closed by using conditional loops.
restaurants = [fork_fig, frontier_restaurant]
open_restaurants(restaurants)[0]['name'] ###I want restaurant name to be appear
Below is the code that I've been working on and cannot quite sure how I can fix this to get the value that I want to return.
def open_restaurants(restaurants):
selected = []
for i in restaurants:
if fork_fig['is_closed']:
selected = restaurants[1]
else:
selected = restaurants[0]
return selected
Continuing from the comment:
fork_fig = {'categories': [{'alias': 'burgers', 'title': 'Burgers'},
{'alias': 'sandwiches', 'title': 'Sandwiches'},
{'alias': 'salad', 'title': 'Salad'}],
'coordinates': {'latitude': 35.10871, 'longitude': -106.56739},
'display_phone': '(505) 881-5293',
'distance': 3571.724649307866,
'id': 'fork-and-fig-albuquerque',
'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/_-DpXKfS3jv6DyA47g6Fxg/o.jpg',
'is_closed': False,
'location': {'address1': '6904 Menaul Blvd NE',
'address2': 'Ste C',
'address3': '',
'city': 'Albuquerque',
'country': 'US',
'display_address': ['6904 Menaul Blvd NE', 'Ste C', 'Albuquerque, NM 87110'],
'state': 'NM',
'zip_code': '87110'},
'name': 'Fork & Fig',
'phone': '+15058815293',
'price': '$$',
'rating': 4.5,
'review_count': 604}
frontier_restaurant = {'categories': [{'alias': 'mexican', 'title': 'Mexican'},
{'alias': 'diners', 'title': 'Diners'},
{'alias': 'tradamerican', 'title': 'American (Traditional)'}],
'coordinates': {'latitude': 35.0808088832532, 'longitude': -106.619402244687},
'display_phone': '(505) 266-0550',
'distance': 4033.6583235266075,
'id': 'frontier-restaurant-albuquerque-2',
'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/M9L2z6-G0NobuDJ6YTh6VA/o.jpg',
'is_closed': True,
'location': {'address1': '2400 Central Ave SE',
'address2': '',
'address3': '',
'city': 'Albuquerque',
'country': 'US',
'display_address': ['2400 Central Ave SE', 'Albuquerque, NM 87106'],
'state': 'NM',
'zip_code': '87106'},
'name': 'Frontier Restaurant',
'phone': '+15052660550',
'price': '$',
'rating': 4.0,
'review_count': 1369}
restaurants = [fork_fig, frontier_restaurant]
def open_restaurants(restaurants):
selected = []
for i in restaurants:
if 'is_closed' in i:
if not i['is_closed']:
selected.append(i['name'])
return selected
print(open_restaurants(restaurants))
OUTPUT:
['Fork & Fig']
Shorter-version:
Using list-comprehension:
def open_restaurants(restaurants):
return [x['name'] for x in restaurants if 'is_closed' in x and not x["is_closed"]]
print(open_restaurants(restaurants))
Using get() instead of indexing:
def open_restaurants(restaurants):
return [x['name'] for x in restaurants if 'name' in x and not x.get('is_closed', True)]
print(open_restaurants(restaurants))
Use the filter function:
def open_restaurants(restaurants):
return filter(lambda r: not r['is_closed'], restaurants)
Use List Comprehension here. Its one line and easy to read
open_restaurants = [restaurant.get("name") for restaurant in restaurants if not restaurant.get("is_closed")]
Output: ["Fork & Fig"]
There is a simple way to append all your open restaurants to a new list and print their names.
You will need two loops to accomplish this.
Here is how to do it:
restaurants = [fork_fig, frontier_restaurant] # a list of restaurants
def open_restaurants(restaurants):
selected = []
for i in restaurants: # append all open restaurants to a new list
if not i['is_closed']:
selected.append(i)
return selected
my_open_restaurants = open_restaurants(restaurants) # call the function
for rest in my_open_restaurants: # print all the names
print(rest['name'])
In your example the output will be: Fork & Fig
When I tried with my script, I do get response but can't parse the Name and Email from this response as I never worked with json arrays. Hope there is somebody to give me an idea. I tried with:
import requests
from urllib.parse import urlencode
url = 'https://oresapp.asicanada.net/ores.imis.services/api/member/?'
address = '&callback=angular.callbacks._0&city=&companyName=&personName='
xhr = url + urlencode({'address':address})
j = requests.get(xhr).json()
print(j)
And the partial response is like:
[{'EmailAddress': '', 'Zip': '', 'Members': [{'Fax': '', 'FirstLastName': 'Ryley Reat', 'Id': 46648, 'FirstName': 'Ryley', 'FullName': 'Ryley Reat', 'Email': 'zolo#zolo.ca', 'LastName': 'Reat', 'LocationId': 46647, 'Phone': '', 'WebSite': ''}], 'ProvinceCode': '', 'CityRanking': 1.0, 'WorkPhone': '', 'Website': '', 'GeoCodeAddress': 'CANADA', 'GeoCode': {'latitude': 56.130366, 'longitude': -106.346771}, 'City': '', 'FullAddress': 'CANADA', 'Id': 46647, 'Fax': '', 'CompanyNameRanking': 1.0, 'Company': 'Zolo Realty Inc.', 'Country': 'Canada', 'BrokerName': ' '}, {'EmailAddress': '', 'Zip': 'T3H 4W2', 'Members': [{'Fax': '', 'FirstLastName': 'David SandBrand', 'Id': 46646, 'FirstName': 'David', 'FullName': 'David SandBrand', 'Email': 'david#sandbrand.com', 'LastName': 'SandBrand', 'LocationId': 46645, 'Phone': '', 'WebSite': ''}], 'ProvinceCode': 'AB', 'CityRanking': 1.0, 'WorkPhone': '', 'Website': '', 'GeoCodeAddress': '146 West Springs Pl SW Calgary, AB T3H 4W2 CANADA', 'GeoCode': {'latitude': 51.0626195, 'longitude': -114.1907432}, 'City': 'Calgary', 'FullAddress': '146 West Springs Pl SW Calgary, AB T3H 4W2 CANADA', 'Id': 46645, 'Fax': '', 'CompanyNameRanking': 1.0, 'Company': 'Damecca Holdings Ltd', 'Country': 'Canada', 'BrokerName': ' '}, {'EmailAddress': 'c.reception#century21.ca', 'Zip': 'S9V 0N7', 'Members': [{'Fax': '', 'FirstLastName': 'Alex Palmer', 'Id': 45347, 'FirstName': 'Alex', 'FullName': 'Alex Palmer', 'Email': 'alex.palmer#century21.ca', 'LastName': 'Palmer', 'LocationId': 37526, 'Phone': '(306) 821-0138', 'WebSite': ''}, {'Fax': '', 'FirstLastName': 'Becky Hofer', 'Id': 45379, 'FirstName': 'Becky', 'FullName': 'Becky Hofer', 'Email': 'becky.hofer#century21.ca', 'LastName': 'Hofer', 'LocationId': 37526, 'Phone': '(306) 830-9740', 'WebSite': ''}, {'Fax': '', 'FirstLastName': 'Cheryl Fairweather', 'Id': 45346, 'FirstName': 'Cheryl', 'FullName': 'Cheryl Fairweather', 'Email': 'cheryl.fariweather#century21.ca', 'LastName': 'Fairweather', 'LocationId': 37526, 'Phone': '(780) 808-9406', 'WebSite': ''}, {'Fax': '', 'FirstLastName': 'Chris Hassall', 'Id': 45334, 'FirstName': 'Chris', 'FullName': 'Chris Hassall', 'Email': 'chris.hassall#century21.ca', 'LastName': 'Hassall', 'LocationId': 37526, 'Phone': '(780) 871-3838', 'WebSite': ''}
Write before the print(j)
import pdb; pdb.set_trace()
Run your script and then the console will wait for commands, there you can write commands, start playing with your json, remember that a Json are tuples with dictionaries, that can have more tupels or more dictionaries inside, so you will end with something like
print (j[1]['EmailAddress'])
Finally found the solution:
import requests
from urllib.parse import urlencode
url = 'https://oresapp.asicanada.net/ores.imis.services/api/member/?'
address = '&callback=angular.callbacks._0&city=&companyName=&personName='
xhr = url + urlencode({'address':address})
j = requests.get(xhr).json()
for item in j:
print(item['Members'][0]['FirstLastName'],item['Members'][0]['Email'], item['Members'][0]['Phone'])