Skip to content

Instantly share code, notes, and snippets.

Sergio Lucero sergiolucero

Block or report user

Report or block sergiolucero

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tv_scraper.py
import os, requests, time
import sqlite3, pandas as pd
from bs4 import BeautifulSoup
STATIC_FOLDER = os.getenv('STATIC_FOLDER')
CANALES = ['rec-tv','canal-13-c','mega','canal-13','tvn','chilevision','ucv-tv',
'tnt','la-red','fox','tnt','hbo','sony','axn','warner','a-e-mundo',
'universal-channel','space','fx']
# 'tvn-24h'
View comunas_shapefile.py
# https://gis.stackexchange.com/questions/113799/how-to-read-a-shapefile-in-python
# http://geospatialpython.com/2011/09/reading-shapefiles-from-cloud.html
# https://medium.com/@loldja/reading-shapefile-zips-from-a-url-in-python-3-93ea8d727856
# http://andrewgaidus.com/Reading_Zipped_Shapefiles/
# https://gis.stackexchange.com/questions/113799/how-to-read-a-shapefile-in-python
@sergiolucero
sergiolucero / s3down.py
Created Nov 11, 2018
download s3 files
View s3down.py
import boto3
import os, sys
s3 = boto3.resource('s3')
def down(canal,token):
x = os.popen(f'lss3 matinales/audio/{canal}/|find "{token}"').read()
files=[f for f in x.split() if 'mp3' in f]
print(files)
for f in files:
View bestplots.py
# galería de gráficos: gasolinas (heatmap+violines) + ipsa + other good ones
import seaborn as sns
import pandas as pd
#1 IPSA:
#2 CNE
#3
View down_cntv.py
import requests
import pandas as pd
from bs4 import BeautifulSoup
# IDEAS: multas, elencos: http://es.teleserieschile.wikia.com/wiki/Categor%C3%ADa:Teleseries_de_Canal_13
bs=BeautifulSoup(requests.get('https://www.cntv.cl/cntv/site/tax/port/all/taxport_16___1.html').text,'html5')
links = bs.find_all('a')
denuncias=[l for l in links if 'Lo más' in l.text]
droot='https://www.cntv.cl'
df=pd.DataFrame()
@sergiolucero
sergiolucero / transantiago.py
Created Sep 26, 2018
recorridos transantiago 2018
View transantiago.py
import pandas as pd
import folium, requests, time
fm=folium.Map([-33.4,-70.65], zoom_start=12)
#LINEAS = ['101','206', '345']
recorridos = eval(requests.get('http://www.transantiago.cl/restservice/rest/getservicios/all').text)
LINEAS = recorridos #[:10]
View compila_acordes.py
from docx import Document
def compilar_cancionero(artista):
data_canciones = recopila_acordes(artista)
document = Document()
document.add_heading(artista, 0)
for songname, song_chords in data_canciones.items():
@sergiolucero
sergiolucero / artista_la_cuerda.py
Last active Aug 31, 2018
canciones de un artista en LaCuerda.net
View artista_la_cuerda.py
import requests
from bs4 import BeautifulSoup
from operator import methodcaller
url_bs = lambda url: BeautifulSoup(requests.get(url).text,'html5lib') # magic!
def recopila_acordes(artista = 'Manu Chao'): # "Manu Chao" -> manu_chao
fartist = '_'.join(map(methodcaller("lower"),artista.split()))
url = f'https://acordes.lacuerda.net/{fartist}/'
@sergiolucero
sergiolucero / cancionero.py
Last active Aug 29, 2018
Cancionero de La Cuerda
View cancionero.py
#!pip install -q python-docx
import requests
from bs4 import BeautifulSoup
from docx import Document
ubs = lambda url:BeautifulSoup(requests.get(url).text,'html5lib')
def get_chords(artist = 'Manu Chao'):
fartist = '_'.join(s.lower() for s in artist.split()) # use map
url = f'https://acordes.lacuerda.net/{fartist}/'
View airquality.py
# for every city, we fetch and plot data from all available parameters
import openaq
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="white", palette='muted', font_scale=1.35, color_codes=True)
api = openaq.OpenAQ()
def get_city_data(city='Santiago'):
df = api.measurements(city=city, limit=10000, df=True)
df = df.query("value >= 0.0") # clean up the data by removing values below 0
You can’t perform that action at this time.