# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: county-scraping-env
#     language: python
#     name: county-scraping-env
# ---

import pandas as pd
import requests
import json
from datetime import date

# ## Get raw data from [map](https://cocogis.maps.arcgis.com/apps/webappviewer/index.html?id=fea1f3021a50455495b7e7e11325ecd4)

# +
urls = [
'https://services3.arcgis.com/42Dx6OWonqK9LoEE/ArcGIS/rest/services/FoodResources4_9_20_CombinedFrom211/FeatureServer/0/query', # 191
'https://services3.arcgis.com/42Dx6OWonqK9LoEE/arcgis/rest/services/SchoolMealPickups/FeatureServer/0/query', # 617
'https://services3.arcgis.com/42Dx6OWonqK9LoEE/arcgis/rest/services/SeedLibraries/FeatureServer/0/query' # 6
]

dfs = []

params = {
    "f":"json",
    "where":"1=1",
    "returnGeometry":"true",
    "outFields":"*",
}

for url in urls:
  res = requests.get(url, params=params)
  df = pd.json_normalize(json.loads(res.text)['features'])
  dfs.append(df)
# -

dfs[0].head(10)

# +
today = date.today()
filename = 'contra_costa_foodresources_raw_%s.csv' % (today.strftime("%m_%d_%Y"))
dfs[0].to_csv(filename)

filename = 'contra_costa_schoolmeals_raw_%s.csv' % (today.strftime("%m_%d_%Y"))
dfs[1].to_csv(filename)
# -



StarcoderdataJupyterScriptsDedupFiltered