Git Product home page Git Product logo

transparenciaperu's Introduction

transparenciaperu

Shiny app para descargar datos de los portales de transparencia de algunas entidades peruanas

Acceso

Para acceder al aplicativo web puedes hacer click aquí. Allí mismo encontrarás las instrucciones para su uso.

Aportes

Cualquier colaboración es bienvenida. Puedes dirigirte a Issues para agregar alguna sugerencia o reporte de bug. ¡No necesitas saber nada de programación para aportar!

transparenciaperu's People

Contributors

calderonsamuel avatar

Watchers

James Cloos avatar  avatar

transparenciaperu's Issues

Usar GET request para HTML en lugar de xls

Actualmente la app hace consulta para descargar los datos en xls.

Con este código se puede descargar en formato HTML para más fácil manipulación:

library(httr2)
library(rvest)

method_post <- function() {
    request("https://www.transparencia.gob.pe/contrataciones/pte_transparencia_ordenes.aspx") |> 
        req_body_form(
            ch_tipo_busqueda=1,
            id_entidad=2022, 
            id_tema=34, 
            Ver="", 
            in_anno_consulta=2021, 
            ch_mes_consulta=06, 
            cmb_buscar="Enviar"
        ) |> 
        req_perform()
}

method_get <- function() {
    request("https://www.transparencia.gob.pe/contrataciones/pte_transparencia_ordenes.aspx") |> 
        req_url_query(
            in_anno_consulta=2021, 
            ch_mes_consulta="06", 
            id_entidad=2022, 
            id_tema=34,
            pag=1
        ) |> 
        req_perform()
}

# Para procesar y obtener la tabla
table_get <- function(x) {
    x |> 
        resp_body_html() |> 
        html_element(".table") |> 
        html_table(header = TRUE)
}

El método POST solo retorna la primera página, por lo que al final se prefiere el método GET.

Tomar en cuenta lo mucho que pueden tardar. En el peor de los casos cerca de los 40 segundos por request.

# Unit: seconds
#  expr      min       lq     mean   median       uq      max neval
#  post 1.425692 2.205296 5.891176 3.355373 5.168499 37.72443    50
#   get 1.566802 2.386330 5.106356 3.495146 5.409074 37.90098    50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.