Skip to main content
Tweeted twitter.com/StackMma/status/1543837008237400065
Added explanation for CJK acronym
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

CorrectWhen importing content containing Chinese (CJK) characters, correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

screenshot of correct output

But when using URLSubmit, the output is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

screenshot: output contains weird characters

Correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

screenshot of correct output

But when using URLSubmit, the output is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

screenshot: output contains weird characters

When importing content containing Chinese (CJK) characters, correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

screenshot of correct output

But when using URLSubmit, the output is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

screenshot: output contains weird characters

Shortened title, formatted code
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

How to solve the problem of garbled Garbled code when using URLSubmit[] to request CJK web page

Correct results can be obtained by using URLreadURLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

enter image description herescreenshot of correct output

But when using URLSubmitURLSubmit, itthe output is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

enter image description herescreenshot: output contains weird characters

How to solve the problem of garbled code when using URLSubmit[] to request CJK web page

Correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

enter image description here

But when using URLSubmit, it is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

enter image description here

Garbled code when using URLSubmit[] to request CJK web page

Correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

screenshot of correct output

But when using URLSubmit, the output is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

screenshot: output contains weird characters

Became Hot Network Question
Source Link

How to solve the problem of garbled code when using URLSubmit[] to request CJK web page

Correct results can be obtained by using URLread

URLRead["https://zhuanlan.zhihu.com/p/35359905", "Body"]

enter image description here

But when using URLSubmit, it is garbled

URLSubmit[
 HTTPRequest["https://zhuanlan.zhihu.com/p/35359905", 
  CharacterEncoding -> "UTF-8"], 
 HandlerFunctions -> <|"BodyReceived" -> ((body = #Body) &)|>]

enter image description here