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/20 03:32] – numeroteca | airbnb:recetas [2019/03/21 23:43] (actual) – [Preguntas y manuales] numeroteca | ||
|---|---|---|---|
| Línea 4: | Línea 4: | ||
| Esta página recoge diferentes recetas y scripts para facilitar el análisis en diferentes lenguages y herramientas. | Esta página recoge diferentes recetas y scripts para facilitar el análisis en diferentes lenguages y herramientas. | ||
| + | |||
| + | ===== Documentación tipo ===== | ||
| + | |||
| + | Para documentar una pregunta que aún no esté en wiki hay que crear una nueva página y se puede copiar la estructura de documentación de la siguiente plantilla: [[: | ||
| ===== Preguntas y manuales | ===== Preguntas y manuales | ||
| Línea 14: | 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 46: | Línea 57: | ||
| Desde Terraferida [[https:// | Desde Terraferida [[https:// | ||
| + | ===== 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: | ||
| + | |||
| + | <code python> | ||
| + | import csv | ||
| + | import urllib2 | ||
| + | from bs4 import BeautifulSoup | ||
| + | |||
| + | outputpath = " | ||
| + | hdr = {' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | |||
| + | with open(outputpath, | ||
| + | |||
| + | writer = csv.writer(outfile) | ||
| + | for counter in [102947901, | ||
| + | |||
| + | url = " | ||
| + | | ||
| + | print url | ||
| + | # Get URL | ||
| + | response = urllib2.Request(url, | ||
| + | pagedata = urllib2.urlopen(response) | ||
| + | html = pagedata.read() | ||
| + | # Get links | ||
| + | soup = BeautifulSoup(html, | ||
| + | # boxes = soup.select(" | ||
| + | title = soup.select(" | ||
| + | since = soup.select(" | ||
| + | review = soup.select("# | ||
| + | review = review.translate(None, | ||
| + | desc= soup.select(" | ||
| + | print counter | ||
| + | print title | ||
| + | print since | ||
| + | print review | ||
| + | print desc | ||
| + | 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, | ||
| + | </ | ||
| ===== SQL ===== | ===== SQL ===== | ||
airbnb/recetas.1524187966.txt.gz · Última modificación: por numeroteca