0

newbb got a question about character problem between google and webpage table.

I'm using google sheet and script to get a table from a opened website to google spreadsheet.

the page url is below (um.. I have reputation limit)

http://www.mogef.go.kr/system/korea/board/photo/photo.jsp?bid=341

At first time I used google spreadsheet function 'importhtml'.

The tables works fine but the language is changed weird. I've changed google language option but didn't work.

picture of character problem at google sheet

so I trying to get HTML of table in google script by following api fetch example and

I thought this problem comes from charset.. encoding.. or something

so added an option about charset ('euc-kr' from the page HTML source)

 //in google apps script   
function myFunction() {
      var option = 
      {
      "contentType" : "charset=euc-kr"
      };
       var response = UrlFetchApp.fetch("~~~url~~~", option);
     Logger.log(response.getContentText());
    }

And It success to take HTML as text

but the language(same above language) looks like this..

diamond characters

How can I solve this problem..? I need normal text table or HTML text in google sheet or script. without MS excel.

12423145642
  • 27
  • 1
  • 7

1 Answers1

2

According to the docs you can pass a charset to getContentText:

response.getContentText('EUC-KR')

This should return the characters correctly.

https://developers.google.com/apps-script/reference/url-fetch/http-response#getcontenttextcharset

Cameron Roberts
  • 7,127
  • 1
  • 20
  • 32