how to read chinese character? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to read chinese character? (/thread-38039.html) |
how to read chinese character? - kucingkembar - Aug-25-2022 Hi, I try to translate a Chinese page to an English page, but the result is gibberish, how to "convert" It to Chinese? # importing the modules import requests from bs4 import BeautifulSoup # target url url = "https://www.boshisw.com/boshi/14_14309/" # making requests instance reqs = requests.get(url) # using the BeautifulSoup module soup = BeautifulSoup(reqs.text, 'html.parser') # displaying the title print("Title of the website is : ") for title in soup.find_all('title'): print(title.get_text()) thank you for reading, have a nice day
RE: how to read chinese character? - snippsat - Aug-25-2022 Change to reqs.content .This mean that Bs4 is given bytes and it will deal with Unicode,using reqs.text it can be mix up between Requests and Bs4.Encodings Quote:Any HTML or XML document is written in a specific encoding like ASCII or UTF-8. # importing the modules import requests from bs4 import BeautifulSoup # target url url = "https://www.boshisw.com/boshi/14_14309/" # making requests instance reqs = requests.get(url) # using the BeautifulSoup module soup = BeautifulSoup(reqs.content, 'html.parser') print(type(soup)) # displaying the title print("Title of the website is : ") for title in soup.find_all('title'): print(title.get_text())
RE: how to read chinese character? - kucingkembar - Aug-25-2022 (Aug-25-2022, 07:47 PM)snippsat Wrote: Change to thank you, i looking this for hours, i give you reputation point |