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 scraper_denuncias_CNTV.py
import requests, pandas as pd
from bs4 import BeautifulSoup
pd.set_option('max_colwidth',-1)
base_url = 'https://www.cntv.cl/cntv/site/tax/port/all/taxport_16___1.html'
bs = BeautifulSoup(requests.get(base_url).text, 'lxml')
top = pd.DataFrame()
links = [link for link in bs.find_all('a') if 'más' in link.text]
print(f'{len(links)} meses de denuncias')
View cntv_scraper_multas.py
import requests, pandas as pd
from bs4 import BeautifulSoup
CLIO_DEF = 'https://www.yapo.cl/chile/inmuebles?ca=15_s&l=0&q=casa&cmn=&st=a'
def text_search(bs, classname):
return [p0.text.strip()
for p0 in bs.find_all('span', attrs={'class': classname})]
def scrape_yapo(url = CLIO_DEF):
View cntv_scraper.py
import requests, pandas as pd
from bs4 import BeautifulSoup
CLIO_DEF = 'https://www.yapo.cl/chile/inmuebles?ca=15_s&l=0&q=casa&cmn=&st=a'
def text_search(bs, classname):
return [p0.text.strip()
for p0 in bs.find_all('span', attrs={'class': classname})]
def scrape_yapo(url = CLIO_DEF):
View cliente_deudor.json
{
"nodes": [
{
"id": "DAG INGENIERIA Y CONSTRU",
"group": 0
},
{
"id": "ALBEMARLE LIMITADA (ROCK",
"group": 1
},
@sergiolucero
sergiolucero / graphqlapp.py
Created Jun 20, 2019
basic flask-graphql app
View graphqlapp.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from flask_graphql import GraphQLView
#################################
app = Flask(__name__)
app.debug = True
@sergiolucero
sergiolucero / outlook_reader.py
Created Jun 6, 2019
parsing outlook folders
View outlook_reader.py
import os, time
from pprint import pprint
from collections import defaultdict
from win32com.client import Dispatch
t0 = time.time()
outlook=Dispatch("Outlook.Application").GetNamespace("MAPI")
#inbox = outlook.GetDefaultFolder("6")
confi = outlook.Folders(2).Folders(2) # found by trial and error
counts = defaultdict(int)
@sergiolucero
sergiolucero / csv_to_geojson.py
Created Jun 5, 2019
shapefile_geojson from CSV
View csv_to_geojson.py
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
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:
You can’t perform that action at this time.