Skip to content

Instantly share code, notes, and snippets.

View robsalasco's full-sized avatar
🏠
Working from home

Roberto Salas robsalasco

🏠
Working from home
View GitHub Profile
# Proof of concept - Extract data from REDATAM web interface (CENSUS 2017) directly to R
library(httr)
library(rvest)
headers <- add_headers(
"User-Agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36",
"Referer" = "https://redatam-ine.ine.cl/redbin/RpWebStats.exe/AreaList?BASE=CENSO_2017&ITEM=AREAPOB&lang=esp",
"Host" = "redatam-ine.ine.cl",
"X-Requested-With" = "XMLHttpRequest"
library(httr)
library(rvest)
headers <- add_headers(
"User-Agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36",
"Referer" = "https://redatam-ine.ine.cl/redbin/RpWebStats.exe/CmdSet?BASE=CENSO_2017&ITEM=PROGRED&lang=esp",
"Host" = "redatam-ine.ine.cl",
"X-Requested-With" = "XMLHttpRequest"
)
@robsalasco
robsalasco / test.R
Last active February 1, 2019 00:36
library(geojsonio)
library(dplyr)
library(purrr)
library(stringr)
d <- geojsonio::geojson_read("https://raw.githubusercontent.com/robsalasco/precenso_2016_geojson_chile/master/Comunas/R01.geojson", method = "local", what = "sp")
regiones_names_list <- c("region_id", "region_name")
provincias_names_list <- c("region_id", "provincia_id",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
library(httr)
library(rvest)
headers <- add_headers(
"User-Agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36",
"Referer" = "https://redatam-ine.ine.cl/redbin/RpWebStats.exe/CmdSet?BASE=CENSO_2017&ITEM=PROGRED&lang=esp",
"Host" = "redatam-ine.ine.cl",
"X-Requested-With" = "XMLHttpRequest"
)
h3 valor
88b2c55437fffff 3631
88b2c55435fffff 4226
88b2c555cbfffff 1145
88b2c555ddfffff 2334
88b2c555d9fffff 251309
88b2c55433fffff 198530
88b2c55431fffff 2574
88b2c5543dfffff 308847
88b2c55423fffff 3058
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from requests import get
from lxml import html, etree
import camelot
import pandas as pd
import numpy as np
url = 'https://www.minsal.cl/nuevo-coronavirus-2019-ncov/casos-confirmados-en-chile-covid-19/'
response = get(url)