Skip to content

Commit

Permalink
Encoding problem in search
Browse files Browse the repository at this point in the history
The results were incorrectly encoded.
  • Loading branch information
wilsonfreitas committed Oct 30, 2020
1 parent 49f571c commit 07fb9b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 1 addition & 3 deletions R/rbcb_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
search_series <- function(q, page = 1) {
url <- search_series_url(q, page = page)
res <- http_getter(url)

# x <- httr::content(res, as = 'text')
x <- http_gettext(res)
x <- httr::content(res, as = 'text', encoding = "UTF-8")
doc <- xml2::read_html(x)

nodes <- xml2::xml_find_all(doc, '//*[@class="dataset-item"]')
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-search.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

context('Search series')

test_that('should check if encoding is ok', {
x <- search_series("IPCA")

expect_equal(x[[1]][[1]]$title,
"Índice de Preços ao Consumidor-Amplo (IPCA) - Não comercializáveis")
})

0 comments on commit 07fb9b1

Please sign in to comment.