Git Product home page Git Product logo

Comments (5)

jmesquita avatar jmesquita commented on July 22, 2024

En #74 esta el PR que soluciona este tema.

from preciosa.

mgaitan avatar mgaitan commented on July 22, 2024

hice esto

In [1]: ciudades = City.objects.filter(country__name='Argentina', population__gt=50000)

In [2]: ciudades
Out[2]: [<City: Azul, Buenos Aires, Argentina>, <City: Bahía Blanca, Buenos Aires, Argentina>, <City: Barranqueras, Chaco, Argentina>, <City: Buenos Aires, Buenos Aires F.D., Argentina>, <City: Campana, Buenos Aires, Argentina>, <City: Chimbas, San Juan, Argentina>, <City: Chivilcoy, Buenos Aires, Argentina>, <City: Cipolletti, Río Negro, Argentina>, <City: Colegiales, Buenos Aires F.D., Argentina>, <City: Comodoro Rivadavia, Chubut, Argentina>, <City: Concepción del Uruguay, Entre Ríos, Argentina>, <City: Concordia, Entre Ríos, Argentina>, <City: Corrientes, Corrientes, Argentina>, <City: Córdoba, Córdoba, Argentina>, <City: Formosa, Formosa, Argentina>, <City: General Pico, La Pampa, Argentina>, <City: General Roca, Río Negro, Argentina>, <City: Gobernador Gálvez, Santa Fe, Argentina>, <City: Goya, Corrientes, Argentina>, <City: Gualeguaychú, Entre Ríos, Argentina>, '...(remaining elements truncated)...']

In [3]: ciudades.count()
Out[3]: 72

In [4]: from pyquery import PyQuery

In [5]: results = []

In [6]: def parse(r):
   ...:     pq = PyQuery(r.content)
   ...:     return pq('div.storelocator_result')
   ...: 

In [7]: for city in ciudades:
   ...:     r = requests.post('http://www.carrefour.com.ar/storelocator/index/search/', {'search[address]': 'Mendoza, Argentina', 'search[geocode]': '%s, %s' % (city.latitude, city.longitude)  })
   ...:     results.extends(parse(r))
In [8]: html = '\n\n'.join(PyQuery(r).html() for r in results)

In [9]: f = open('sucursales_carrefour.html', 'w')

In [10]: f.write(html.encode('utf8'))
In [11]: pq =  PyQuery(html)
In [12]: set([pq(a).text() for a in  pq('.name a')])
Out[23]: 
set(['458 - LOMAS DE ZAMORA',
     '638 - DERQUI',
     '168 - SAN SALVADOR DE JUJUY',
     u'256 - SAN NICOL\xc1S',
     u'177 - SAN MIGUEL DE TUCUM\xc1N',
     '473 - LA MATANZA',
     '171 - SALTA',
     '589 - MONSERRAT',
     '255 - PERGAMINO',
     '284 - MENDOZA',
     '437 - SAN ISIDRO',
     u'264 - PARAN\xc1',
     u'125 - PARAN\xc1',
     '187 - ESCOBAR',
     u'446 - LAN\xdaS',
     '162 - TRELEW',
     u'181 - PARAN\xc1',
     u'249 - PARAN\xc1',
     '25 - SAN FERNANDO',
     '8 - LA PLATA',
     '43 - HAEDO',
     u'644 - C\xd3RDOBA',
     '32 - ROSARIO',
     '109 - LA PLATA',
     '585 - CONSTITUCION',
     u'606 - C\xd3RDOBA',
     '431 - SAN FERNANDO',
     u'157 - NEUQU\xc9N',
     u'297 - GRAL. RODR\xcdGUEZ',
     '175 - SALTA',
     u'655 - SAN NICOL\xc1S',
     '477 - LA MATANZA',
     '44 - RESISTENCIA',
     u'246 - PARAN\xc1',
     u'119 - R\xcdO CUARTO',
     u'263 - PARAN\xc1',
     '649 - LINIERS',
     '21 - MORENO',
     '605 - MATADEROS',
     '33 - ROSARIO',
     u'262 - PARAN\xc1',
     '22 - MAR DEL PLATA',
     '148 - 9 DE JULIO',
     u'139 - OLAVARR\xcdA',
     '62 - PILAR',
     '137 - SAN LUIS',
     '259 - VENADO TUERTO',
     '465 - AVELLANEDA',
     '600 - FLORES',
     '285 - MENDOZA',
     '438 - MALVINAS ARGENTINAS',
     '290 - MENDOZA',
     '361 - BELGRANO',
     '232 - CAMPANA',
     '9 - VILLA URQUIZA',
     '29 - MENDOZA',
     '395 - CHACARITA',
     '703 - MORENO',
     u'156 - SAN NICOL\xc1S',
     '251 - PALERMO',
     '58 - BALCARCE',
     '221 - TIGRE',
     '12 - SAN JUSTO',
     '149 - BARILOCHE',
     '433 - PILAR',
     '178 - CATAMARCA',
     '183 - ING. MASCHWITZ',
     '208 - CAMPANA',
     u'294 - ITUZAING\xd3',
     '42 - MERLO',
     u'243 - PARAN\xc1',
     '408 - SAN TELMO',
     '287 - MENDOZA',
     '112 - SALTA',
     '351 - BELGRANO',
     u'240 - GUALEGUAYCH\xda',
     '165 - PUERTO MADRYN',
     '657 - MATADEROS',
     '488 - MONSERRAT',
     '159 - CORRIENTES',
     '443 - QUILMES',
     '454 - QUILMES',
     '450 - ALMIRANTE BROWN',
     '283 - MENDOZA',
     '182 - BELGRANO',
     u'50 - QUINTAS DE ARG\xdcELLO',
     '282 - MENDOZA',
     '484 - MORENO',
     '461 - LOMAS DE ZAMORA',
     u'17 - GUAYMALL\xc9N',
     '444 - FLORENCIO VARELA',
     '56 - GLEW',
     '38 - PANAMERICANO',
     '233 - CONCORDIA',
     '464 - LOMAS DE ZAMORA',
     '702 - CLAYPOLE',
     u'244 - PARAN\xc1',
     '435 - ESCOBAR',
     u'10 - MOR\xd3N',
     '31 - TANDIL',
     '146 - TRELEW',
     '123 - SAN JUAN',
     '289 - MENDOZA',
     '141 - FORMOSA',
     '452 - QUILMES',
     '449 - FLORENCIO VARELA',
     '495 - BERAZATEGUI',
     '235 - SAN LUIS',
     u'210 - Z\xc1RATE',
     u'653 - C\xd3RDOBA',
     u'293 - SAN MIGUEL DE TUCUM\xc1N',
     '161 - USHUAIA',
     '144 - LA PLATA',
     '108 - RESISTENCIA',
     '385 - SAN TELMO',
     '228 - COLEGIALES',
     u'642 - C\xd3RDOBA',
     '343 - COLEGIALES',
     '531 - PALERMO',
     '286 - MENDOZA',
     '448 - ALMIRANTE BROWN',
     '467 - MORENO',
     u'266 - PARAN\xc1',
     '554 - VILLA RIACHUELO',
     '291 - MONSERRAT',
     u'424 - LUJ\xc1N',
     '45 - TRELEW',
     '167 - SAN SALVADOR DE JUJUY',
     '41 - ROSARIO',
     '583 - MONSERRAT',
     u'53 - NEUQU\xc9N',
     '279 - MENDOZA',
     u'48 - R\xcdO GALLEGOS',
     u'647 - C\xd3RDOBA',
     '481 - LA MATANZA',
     '63 - CALETA OLIVIA',
     u'610 - C\xd3RDOBA',
     '135 - LA RIOJA',
     '18 - ROSARIO',
     '275 - BELGRANO',
     '288 - MENDOZA',
     '476 - LA MATANZA',
     '147 - SANTA ROSA',
     '359 - MONSERRAT',
     u'442 - MOR\xd3N',
     '386 - MONSERRAT',
     '272 - SAN FERNANDO',
     '512 - PILAR',
     '601 - YERBA BUENA',
     '633 - MONSERRAT',
     '474 - MERLO',
     '59 - GODOY CRUZ',
     u'143 - R\xcdO GALLEGOS',
     '423 - VILLA LUGANO',
     '132 - CATAMARCA',
     '229 - PERGAMINO',
     '122 - SAN SALVADOR DE JUJUY',
     '295 - ALTO VERDE',
     '524 - MERLO',
     u'142 - R\xcdO GRANDE',
     '57 - TANDIL',
     '180 - RIO GRANDE',
     '55 - FORMOSA',
     '445 - LA PLATA',
     '479 - MERLO',
     '51 - TIGRE',
     '494 - MALVINAS ARGENTINAS',
     '179 - PUERTO MADRYN',
     u'701 - G\xd3NZALEZ CAT\xc1N',
     '559 - PALERMO',
     '634 - MONSERRAT',
     '475 - LA MATANZA',
     '128 - COMODORO RIVADAVIA',
     u'459 - LAN\xdaS',
     u'241 - LUJ\xc1N',
     u'427 - MOR\xd3N',
     '28 - PILAR',
     u'308 - SAN NICOL\xc1S',
     '292 - COMODORO RIVADAVIA',
     '457 - ALMIRANTE BROWN',
     '405 - MATADEROS',
     '478 - 3 DE FEBRERO',
     '227 - BERNAL',
     '110 - CORRIENTES',
     u'379 - SAN NICOL\xc1S',
     '320 - BELGRANO',
     u'296 - OLAVARR\xcdA',
     '499 - LA MATANZA',
     '535 - VILLA LUGANO',
     u'46 - SAN MIGUEL DE TUCUM\xc1N',
     '205 - PALOMAR',
     '7 - QUILMES',
     '422 - LOMAS DE ZAMORA',
     u'648 - C\xd3RDOBA',
     '411 - FLORES',
     '268 - ROSARIO',
     '462 - QUILMES',
     '596 - CHACARITA',
     '138 - CONCORDIA',
     '130 - MAR DEL PLATA',
     u'439 - MOR\xd3N',
     '440 - TIGRE',
     '136 - GENERAL ROCA',
     u'176 - SAN MIGUEL DE TUCUM\xc1N',
     '49 - FLORENCIO VARELA',
     '571 - MONSERRAT',
     '333 - COMODORO RIVADAVIA',
     '274 - QUILMES',
     '483 - LA MATANZA',
     '337 - COLEGIALES',
     u'322 - AGRONOM\xcdA',
     '239 - GRAL. PACHECO',
     '629 - PARQUE AVELLANEDA',
     '451 - ALMIRANTE BROWN',
     '184 - SANTA ROSA',
     u'114 - BAH\xcdA BLANCA',
     '364 - COLEGIALES',
     '134 - TANDIL',
     '534 - MATADEROS',
     '54 - VILLA ALLENDE LOMAS',
     u'607 - C\xd3RDOBA',
     u'641 - C\xd3RDOBA',
     '191 - MAR DEL PLATA',
     '519 - COLEGIALES',
     u'24 - JARD\xcdN ESPINOZA',
     '522 - LA MATANZA'])

In [24]: len(set([pq(a).text() for a in  pq('.name a')]))
Out[24]: 226

O sea, ahi tenemos 226 sucursales distintas, no sé si serán todas.

los datos están en HTML, hay que ver de parsearlos bien

acá el html
https://gist.github.com/mgaitan/9085461

from preciosa.

mgaitan avatar mgaitan commented on July 22, 2024

@jmesquita si tenés data, estamos completando la API en #163 para que se puedan "postear" sucursales. Con eso vamos a importar distintos datasets (ref #162).
Ya no estamos actualizando los fixtures json porque es un lio para consolidar la info,.

Si tenés un script que scrapea los datos, seria piola que utilices esto para "subir" la info al sitio. Chiflá cualquier cosa

from preciosa.

jmesquita avatar jmesquita commented on July 22, 2024

Estoy en camino de Brasil ahora y voy a meterle algo hoy a la noche cuando llegue.

Sent from my iPhone

On Mar 8, 2014, at 12:47 AM, Martín Gaitán [email protected] wrote:

@jmesquita si tenés data, estamos completando la API en #163 para que se puedan "postear" sucursales. Con eso vamos a importar distintos datasets (ref #162).
Ya no estamos actualizando los fixtures json porque es un lio para consolidar la info,.

Si tenés un script que scrapea los datos, seria piola que utilices esto para "subir" la info al sitio. Chiflá cualquier cosa


Reply to this email directly or view it on GitHub.

from preciosa.

mgaitan avatar mgaitan commented on July 22, 2024

generamos un CSV importable https://gist.github.com/mgaitan/9677204

from preciosa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.