I'm working on a simple script to scrape data from HTML tables. Problem is that table contains special characters, even if it says it's downloaded as utf-8.
library(XML)
webpage.Name <- "http://www.registeruz.sk/cruz-public/domain/financialreport/show/4817607"
webpage.Name.table <- readHTMLTable(webpage.Name, header=T, which=1,stringsAsFactors=F)
Example of data scraped:
V1 V2
1 Mimoriadna <NA>
2 <NA>
3 Ă<U+009A>ÄŤtovná jednotka: malá
4 DaĹ<U+0088>ovĂ© identifikaÄŤnĂ© ÄŤĂslo: 2023790373
I tried using gsub and changing certain paterns but it doesn't seem to work. Same with iconv from utf-8 to latin1. It doesn't matter if the data after the scraping contains special characters or not.
Use encoding = "UTF-8"
in readHTMLTable()
df <- readHTMLTable(webpage.Name,
header = TRUE, which = 1, stringsAsFactors = FALSE, encoding = "UTF-8")
head(df, 4)
# V1 V2
# 1 Mimoriadna <NA>
# 2 <NA>
# 3 Účtovná jednotka: malá
# 4 Daňové identifikačné číslo: 2023790373
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.