I have following html document:
library(rvest)
sess <- html_session("http://www.sudacka-mreza.hr/sudska-praksa.aspx", encoding = "UTF-8")
form <- html_form(sess)[[1]]
fill_form <- set_values(form, 'uc_login1$LoginUserName' = 'mislav.sagovac@contentio.biz',
'uc_login1$LoginPassword' = 'theanswer')
sess_submit <- submit_form(sess, fill_form, submit = "uc_login1$LoginSubmitButton", encoding = "UTF-8")
praxis <- sess_submit %>%
jump_to( "odluke.aspx?Search=&Search2=&Court=112&Type=---&Type1=---&Type1a=---&Type2=---&Type2a=---&Type3=&Type4=&O1=&O2=&O3=&O4=&P1=&P2=&ShowID=21216"
, encoding = "UTF-8")
decision <- read_html(praxis, encoding = "UTF-8") %>%
html_nodes(xpath = "//*[@id='mainContent']")
I want to save decision as html. I tried several solutions (using write_html, read.table) but some of UTF-8 characters are not displayed right in html file.
Tried solutions:
# first tried solutions
decision <- paste(as.character(decision), collapse = "\n")
write.table(decision,
file=paste0("some_path.html"),
quote = FALSE,
col.names = FALSE,
row.names = FALSE
# fileEncoding = "UTF-8"
)
# second tried solutions
writeLines(iconv(decision,
from = "CP1252", to = "UTF8"),
file(paste0("some_path.html"),
encoding="UTF-8"))