Skip to content
조회 수 3180 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

python html tag 제거 경로 금지 문자 제거

 

 

from pytube import YouTube
 
# 경로 금지 문자 제거, HTML문자 제거
import re
def filename_remover(string):
        cleaner = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});') #<tag>, &nbsp 등등 제거
        string = re.sub(cleaner, '', string)
        while(string[-1] == '.'):
            string = string[:-1] #끝에 . 제거 ex) test... -> test
        non_directory_letter = ['/', ':', '*', '?', '<', '>', '|'] #경로 금지 문자열 제거
        for str_ in non_directory_letter:
                if str_ in string:
                        string = string.replace(str_, "")
        return string
 
url = 'https://www.youtube.com/watch?v=FbVeMmO6G60&t=1s'
yt = YouTube(url)
 
caption = yt.captions.all()[0]  # 첫번째 자막 선택
caption_xml=caption.xml_captions # html문서로 변환
re_string=filename_remover(caption_xml)
print(re_string)

 

 

로그인 후 댓글쓰기가 가능합니다.

?

  1. 25
    Feb 2023
    12:03

    파이썬으로 비활성화 된 창의 이미지를 캡쳐하는 방법

    Category파이썬 Views4003
    Read More
  2. 25
    Feb 2023
    12:36

    파이썬 비활성화 된 창 활성화 시키기

    Category파이썬 Views3551
    Read More
  3. 04
    Mar 2023
    08:39

    python class def

    Category파이썬 Views2366
    Read More
  4. 04
    Mar 2023
    08:47

    파이썬 변수가 정의되었는지 여부 확인방법코드

    Category파이썬 Views3986
    Read More
  5. 10
    Mar 2023
    14:09

    네이버 주식에서 종목의 투자정보 자료 가져오기

    Category파이썬 Views2245
    Read More
  6. 10
    Mar 2023
    14:33

    네이버 주식의 기업정보와 펀더멘탈정보 소스 가져오기

    Category파이썬 Views3366
    Read More
  7. 15
    Mar 2023
    04:01

    웹 페이지에서 동적으로 생성되는 데이터 가져오는 방법

    Category파이썬 Views6937
    Read More
  8. 25
    Mar 2023
    09:40

    파이썬에서 captCha 분석 프로그램을 만들 수 있을까?

    Category파이썬 Views11723
    Read More
  9. 25
    Mar 2023
    12:40

    파이썬으로 captCha 분석하여 웹사이트 소스 가져오기

    Category파이썬 Views19039
    Read More
  10. 21
    Apr 2023
    20:10

    DiffusionWrapper has 859.52 M params.

    Category파이썬 Views37395
    Read More
  11. 07
    May 2023
    04:17

    python AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' 해결방법

    Category파이썬 Views47514
    Read More
  12. 14
    Sep 2023
    22:34

    한우경매낙찰 유튜브 영상의 이미지에서 특정 문자 가져와서 저장하기

    Category파이썬 Views76543
    Read More
  13. 15
    Sep 2023
    14:04

    파이썬에서 인식이 잘되는 OCR 종류

    Category파이썬 Views77248
    Read More
  14. 04
    Oct 2023
    23:29

    파이썬 랜덤으로 시험문제 풀기

    Category파이썬 Views73099
    Read More
  15. 04
    Oct 2023
    23:33

    파이썬 랜덤으로 문제풀기 #2

    Category파이썬 Views76838
    Read More
  16. 13
    Nov 2023
    05:45

    파이썬 requestsbeautifulsoup 으로 웹 input에 입력값 대입한 뒤 결과값 파일로 저장하기

    Category파이썬 Views64543
    Read More
Board Pagination Prev 1 2 3 Next
/ 3

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소