웹 서버/크롤러

re활용하기

상감자 2018. 5. 16. 12:49

re활용 예제

from bs4 import BeautifulSoup

import re


html = """<html><head><title>title name</title></head><body><p>test</p></body></html>"""


soup = BeautifulSoup(html, 'lxml')

html_content = soup.find_all('html')


print(soup.find_all(re.compile('원하는 정규식')))

print(soup.find_all(class_=re.compile('원하는 정규식')))