본문 바로가기

리눅스

리눅스 html2text 명령어 사용법 정리

반응형

리눅스 html2text 명령어 사용법 정리

html2text는 HTML을 텍스트로 변환하는 도구이며 이를 사용하여 HTML을 해석하고 텍스트로 변환하여 출력합니다.

html2text 패키지 설치

CentOS

sudo yum install -y html2text

Ubuntu

sudo apt-get update
sudo apt-get install -y html2text

HTML 파일을 텍스트로 변환

html2text index.html

출력을 파일에 저장하려면 다음과 같이 리디렉션을 사용

html2text index.html > output.txt
728x90

curl 명령어로 HTML을 요청하고 해석된 결과를 출력하는 방법

curl -s URL | html2text
curl -s 172.19.0.10
$ curl -s 172.19.0.10                      
<!DOCTYPE html>
<html>
        <head>
                <title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
        </head>
        <body>
                <h1>Welcome to nginx!</h1>
                <p>node01 - 172.19.0.3</p>
                <p><em>Thank you for using nginx.</em></p>
        </body>
</html>
curl -s 172.19.0.10 | html2text
$ curl -s 172.19.0.10 | html2text
****** Welcome to nginx! ******
node01 - 172.19.0.3
Thank you for using nginx.
curl -sk https://ha.sangchul.kr | html2text
$ curl -sk https://ha.sangchul.kr | html2text
****** Welcome to nginx! ******
node01 - 172.19.0.3
Thank you for using nginx.

 

이제 설치가 완료되었으며 html2text 명령을 사용하여 HTML 파일을 텍스트로 변환할 수 있습니다.

 

728x90
반응형