Website Translation
    • PDF

    Website Translation

    • PDF

    기사 요약

    Classic/VPC 환경에서 이용 가능합니다.

    Papago Doc Translation 예제를 소개합니다.

    웹 번역 영역 추출

    html 파라미터 크기로 인해 응답이 느려지는 상황이 발생하지 않도록 번역 영역을 추출하는 예제를 설명합니다.

    Python

    className으로 번역할 영역을 추출하는 HTML 기반의 예제 코드는 다음과 같습니다.

    <!DOCTYPE html>
    <html lang="ko">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Example</title>
    </head>
      <body>
        <!-- comments -->
        <ul class="comment_container">
          <!-- comment -->
          <li class="comment_item_wrapper">
            <div class="user_info">
              <span class="nickname">user1</span>
            </div>
            <div class="content">
              <p>
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus
                nostrum in earum minus voluptates nobis fugiat rerum totam illum
                ipsum.
              </p>
            </div>
          </li>
          <!-- comment -->
    
          <!-- comment -->
          <li class="comment_item_wrapper">
            <div class="user_info">
              <span class="nickname">user2</span>
            </div>
            <div class="content">
              <p>Lorem ipsum dolor sit amet.</p>
            </div>
          </li>
          <!-- comment -->
    
          <!-- comment -->
          <li class="comment_item_wrapper">
            <div class="user_info">
              <span class="nickname">user3</span>
            </div>
            <div class="content">
              <p>
                Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ex tempora
                ipsa iusto temporibus consectetur. Libero sequi consequatur
                quibusdam dignissimos totam, praesentium harum dolor nisi
                repudiandae in error tempora incidunt aperiam.
              </p>
            </div>
          </li>
          <!-- comment -->
    
          <!-- comment -->
          <li class="comment_item_wrapper">
            <div class="user_info">
              <span class="nickname">user4</span>
            </div>
            <div class="content">
              <p>
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus
                nostrum in earum minus voluptates nobis fugiat rerum totam illum
                ipsum.
              </p>
              <br />
              <p>Lorem ipsum dolor sit amet.</p>
            </div>
          </li>
          <!-- comment -->
        </ul>
        <!-- comments -->
    
        <script>
          const comments = [
            ...document.getElementsByClassName('comment_item_wrapper'),
          ];
          const htmlsToRequest = comments.map((comment) => comment.outerHTML);
    
          console.log(htmlsToRequest);
        </script>
      </body>
    </html>
    

    이 문서가 도움이 되었습니까?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.