Deciphering Korean for crawling using got

I am currently attempting to perform web scraping on a website using the got library.

Below is the simple code that I have written:

import got from 'got';

async function test(){
  const data = await got('https://dhlottery.co.kr/store.do?method=topStore&pageGubun=L645', { encoding: 'utf8'});
  console.log(data.body);

}
test();

The code works fine, but it does not display Korean characters correctly.

An excerpt of the output is shown below:

<div class="foot_txt2">
  <p>Copyright (c) 2018 ȸ&amp;ູ. All rights reserved</p>
  <p> Ȩ Խõ ̸ ּҰ ڵ Ǵ  źϸ, ̸ ݽ Ÿ  ó Ͽ ֽñ ٶϴ.</p>
  <p class="f_blue2">ûҳ  ϰų ÷   ϴ.</p>
</div>

All the corrupted words appear to be in Korean.

I am curious as to why this issue is occurring and how it can be resolved.

Answer №1

I am not familiar with this particular package and have not tested the solution provided below, but it could potentially resolve your issue.

In the example given, you are specifying the utf8 encoding, however, the website in question actually uses EUC-KR encoding...

https://i.sstatic.net/EzrC2.png

To address this issue, try updating the encoding property in your request as shown below:

import got from 'got';

async function test(){
  const url = 'https://dhlottery.co.kr/store.do?method=topStore&pageGubun=L645';

  const data = await got(url, {
    encoding: 'EUC-KR'
  });

  console.log(data.body);

}
test();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular allows for the creation of dynamic content, much like the append function in jQuery

I am currently working with Angular to create a dynamic star rating system. I have implemented a function to generate the code for the stars dynamically, but unfortunately, they are not showing up on the page. Can anyone help me troubleshoot this issue? B ...

I love the idea of the music playing on as I navigate between pages or tabs. Such a cool feature with Next

I'm looking to implement a music player within my next.js application. How can I ensure that the currently playing track doesn't stop when switching between pages? Essentially, I want the music playback to continue seamlessly as users navigate th ...

Choose a single image by clicking on the <img> tag

While working with Angular, I encountered an issue where rendering multiple images using the img tag resulted in all images changing background color when one of them was clicked. I need to find a solution to change only the background color of the image t ...

The sequence of error middleware in Express4

Encountered a series of code execution that seemed unusual. Here's the code snippet: server.js const Actions_Single_PVC = require('./routes/Actions_single_PVC.js'); app.use('/Actions_single_PVC', Actions_Single_PVC); app.use((e ...

JavaScript - splitting numbers into multiple parts

Need help with a JavaScript question regarding numbers like 2,5 or 2.5 I attempted to perform a multi-split operation using the following code: '2.5'.split(/,|./) However, it resulted in an incorrect output: ["", "", "", ""] ...

What is the technique for filtering multiple values using the OR operation in ng-model functions?

Currently, I am using an ng-modal labeled as "myQuery." At the moment, there are two filters in place that look like this: <accordion-group heading="" ng-repeat="hungry_pets in Pets" | filter:{hungry:false} | filter:{name:myQuery}" ... > I have ...

Using ValidationGroup to trigger JavaScript calls from controls

Is it possible to trigger a JavaScript function from the "onclientclick event" of a button that has a ValidationGroup assigned? <asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_Click" ValidationGroup="Valid ...

Emberjs 1.0: Data Changes don't Refresh Computed Property and Template

In my Ember.js application, I am using a datepicker which is integrated for selecting dates. When a date is clicked on the datepicker, a computed property should compare the selected date with the dates available in the timeslot to check for a match. Based ...

Encountering a 404 error when attempting to use the jQuery .load() function with parameters that include periods ('.')

I am attempting to invoke a controller function using the .load() method, but encountering an error which might be caused by the encoding of '.'. The call I am making is as follows: $("#main-content").load( url + "/" + encodeURIComponent(text ...

Implementing a feature in ReactJS that allows users to upload multiple images in base64 format

I'm trying to develop an image uploader using base64 and I want the output as an array. However, I am encountering an issue where the array is coming out empty!. I suspect it might be due to an asynchronous problem. Any tips on how to incorporate asyn ...

Problems with Navbar rendering on multiple occasions

GENERAL INFO I've encountered an issue with the re-rendering of my sidemenu in Gatsby. Despite my efforts, I can't prevent the sidemenu from re-rendering and overriding the data that I set for it. const [activeParent, setActiveParent] = useState ...

Is it possible to rotate an image with a random angle when hovering in Angular?

I'm currently working on a photo gallery project and my goal is to have the images rotate when hovered over. However, I am experiencing difficulties in passing values from TypeScript into the CSS. HTML <div class="back"> <div cl ...

Having trouble loading an image with texture loader in Three.js? The issue may be related to the size and scale of the plane geometry

Can someone please assist me with loading images using TextureLoader? I am encountering a major issue where I am unsure how to add images to a mesh in a 1:1 scale and calculate PlaneGeometry. My goal is to display the loaded image in its original size with ...

Testing in NodeJS - revealing the application

Currently, I am in the process of testing my NodeJS application using supertest. To make my app accessible within test.js at the end of app.js, I have exposed it. /////////////////// // https options var options = { key: fs.readFileSync("./private/key ...

Modify the DOM at a later time once the images have loaded. This particular action is being executed within the context of an

main.ts myFunction(){ this.service.getData().subscribe( response => { this.handleData(response); }, error => console.log(error), () => console.log('request done') ...

Creating dynamic grid data based on various filter criteria using JavaScript (AngularJS)

In my approach, I have created two JSON data files. If the 'List' value equals A-1, I will retrieve the JSON data specific to that value. Otherwise, I will retrieve all the main data from data.json. My goal is to have 3 other checkbox options un ...

I encountered Hydration errors while attempting to use dangerouslySetInnerHTML to render a script on my webpage

My current solution involves utilizing dangerouslySetInnerHTML as a final attempt, as my script fails to execute properly. The specific format is necessary for the plugin to display on the frontend; otherwise, the console reports that ImageMapPro is undefi ...

Exploring location-based services using React-Redux

Seeking a deeper comprehension of redux and the react lifecycle methods. The issue I am facing involves a prop function within the componentDidMount that calls another function in redux. Within redux, I attempt to retrieve location data to set as the init ...

When positioned at high or low angles, the camera starts acting strangely

In my Three.js scene, I have a camera that I need to move and change its angle around a specific focal point. The focal point is actually the camera's position, and during rendering, I translate the camera by using the cameraBuff vector to position it ...

Incorporating PWA functionality into Next.js for seamless notifications and push notifications

I've been working on developing a Progressive Web App (PWA) using next.js and running into some challenges. My goal is to incorporate device motion, geolocation, and notifications into my users' accounts. I'm taking inspiration from this r ...