airbnb:recetas
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| airbnb:recetas [2018/04/22 11:05] – [Python] numeroteca | airbnb:recetas [2019/03/21 23:43] (actual) – [Preguntas y manuales] numeroteca | ||
|---|---|---|---|
| Línea 18: | Línea 18: | ||
| * [[: | * [[: | ||
| * [[: | * [[: | ||
| + | * [[airbnb: | ||
| + | * [[airbnb: | ||
| + | * [[airbnb: | ||
| Por completar: | Por completar: | ||
| + | * [[airbnb: | ||
| + | * [[airbnb: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| - | * [[https:// | + | * [[https:// |
| + | * [[airbnb: | ||
| ===== D3 ===== | ===== D3 ===== | ||
| - | Un cartograma: | + | Cómo realizar un cartograma |
| * Código https:// | * Código https:// | ||
| * Visualización: | * Visualización: | ||
| Línea 51: | Línea 58: | ||
| ===== Python ===== | ===== Python ===== | ||
| + | |||
| + | ==== Scraping: obtiene info a partir de listado de id de hosts en Airbnb ==== | ||
| Un script para scrapear una lista de usuarios de Airbnb basado en sus id: | Un script para scrapear una lista de usuarios de Airbnb basado en sus id: | ||
| Línea 93: | Línea 102: | ||
| print desc | print desc | ||
| writer.writerow([counter, | writer.writerow([counter, | ||
| + | </ | ||
| + | |||
| + | ==== Scraping: obtiene info a partir de listado de id de listings en Airbnb ==== | ||
| + | |||
| + | <code python> | ||
| + | import csv | ||
| + | import urllib2 | ||
| + | from bs4 import BeautifulSoup | ||
| + | |||
| + | outputpath = " | ||
| + | hdr = {' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | |||
| + | count=0 | ||
| + | with open(outputpath, | ||
| + | |||
| + | writer = csv.writer(outfile) | ||
| + | for counter in [23321245, | ||
| + | count +=1 | ||
| + | print count | ||
| + | url = " | ||
| + | | ||
| + | print url | ||
| + | |||
| + | try: | ||
| + | print " | ||
| + | # Get URL | ||
| + | response = urllib2.Request(url, | ||
| + | pagedata = urllib2.urlopen(response) | ||
| + | html = pagedata.read() | ||
| + | # Get links | ||
| + | soup = BeautifulSoup(html, | ||
| + | except: | ||
| + | print " | ||
| + | |||
| + | try: | ||
| + | print " | ||
| + | nreviews = soup.select("# | ||
| + | nreviews = nreviews.translate(None, | ||
| + | lastreview = soup.select("# | ||
| + | except: | ||
| + | print " | ||
| + | | ||
| + | print url | ||
| + | print nreviews | ||
| + | print lastreview | ||
| + | writer.writerow([counter, | ||
| </ | </ | ||
airbnb/recetas.1524387950.txt.gz · Última modificación: por numeroteca