Spaces:
Build error
Build error
File size: 3,037 Bytes
9f36753 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"url = \"https://d3e6htiiul5ek9.cloudfront.net/prod/sucursales\"\n",
"params = {\n",
" \"lat\": -43.9694596,\n",
" \"lng\": -70.5252828,\n",
" \"limit\": 30\n",
"}\n",
"headers = {\n",
" \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0\",\n",
" \"Accept\": \"application/json, text/plain, */*\",\n",
" \"Accept-Language\": \"en-US,en;q=0.5\",\n",
" \"Accept-Encoding\": \"gzip, deflate, br, zstd\",\n",
" \"Origin\": \"https://www.preciosclaros.gob.ar\",\n",
" \"Connection\": \"keep-alive\",\n",
" \"Referer\": \"https://www.preciosclaros.gob.ar/\",\n",
" \"Sec-Fetch-Dest\": \"empty\",\n",
" \"Sec-Fetch-Mode\": \"cors\",\n",
" \"Sec-Fetch-Site\": \"cross-site\",\n",
" \"TE\": \"trailers\"\n",
"}\n",
"\n",
"response = requests.get(url, params=params, headers=headers)\n",
"sucursales = response.json()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"import csv\n",
"with open(\"sucursales.csv\", \"a\", newline=\"\") as file:\n",
" writer = csv.writer(file)\n",
" writer.writerow(sucursales['sucursales'][0].keys())\n",
" for sucursal in sucursales['sucursales']:\n",
" writer.writerow(sucursal.values())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['23-1-6256', '12-1-95', '10-1-41', '10-1-32', '23-1-6262', '12-1-165', '2002-1-101', '10-1-268', '12-1-99', '23-1-6257', '2002-1-6', '12-1-97', '23-1-6260', '2002-1-67', '19-1-00812', '2002-1-38', '24-1-292', '10-1-18', '10-1-33', '2002-1-166', '23-1-6264']\n"
]
}
],
"source": [
"import pandas as pd\n",
"\n",
"# Leer el archivo CSV\n",
"df = pd.read_csv(\"sucursales.csv\")\n",
"\n",
"# Filtrar las filas por provincia\n",
"provincia = \"Rosario\" # Reemplaza con el nombre de la provincia deseada\n",
"sucursales_provincia = df[df['localidad'] == provincia]\n",
"\n",
"# Obtener los IDs de las sucursales\n",
"ids_sucursales = sucursales_provincia['id'].tolist()\n",
"\n",
"print(ids_sucursales)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|