I am working on a web scraping program that feeds into a database, and I have been having problems with UTF-8. Initially, I scraped the data and noticed the special characters were not coming through, so I found that using Encoding() <- "UTF-8" worked.
htmlpage2 <- read_html("http://ift.tt/1cBugZE")
allwines <- data.frame(Wine=html_text(html_nodes(htmlpage2, "h5")),
Description=html_text(html_nodes(htmlpage2, "h5+ p")),
stringsAsFactors=FALSE)
Encoding(allwines$Wine) <- "UTF-8"
Encoding(allwines$Description) <- "UTF-8"
When I created the table in my db, however, the special characters had reverted back.
db <- dbConnect(SQLite(), dbname="WineDB.sqlite")
dbWriteTable(db, "AllWines", allwines, row.names=FALSE, overwrite=TRUE)
Is there a way to change it once for the entire program, even in the database?
Aucun commentaire:
Enregistrer un commentaire