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/21 13:22] – skotperez | 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 50: | 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.1524309745.txt.gz · Última modificación: 2018/04/21 13:22 por skotperez