반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- dfs
- 퇴사통보
- BOJ
- BFS
- 6987
- OFFSET
- 파라메트릭
- msSQL
- @P0
- incr
- softeer
- 연결요소
- 오퍼레터
- 이분탐색
- compose
- 소프티어
- 백트래킹
- 13908
- 매개변수탐색
- 처우협의
- upper_bound
- 기술면접
- 성적평가
- 물채우기
- boj #19237 #어른 상어
- Docker
- Kafka
- 처우산정
- 백준
- 경력
Archives
- Today
- Total
기술 블로그
정규표현식 간단 연습 본문
728x90
반응형
lambda 람다 활용
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import requests from bs4 import BeautifulSoup # 위의 두 모듈이 없는 경우에는 pip install requests bs4 실행 def get_news_content(url): response = requests.get(url) content = response.text soup = BeautifulSoup(content, 'html5lib') div = soup.find('div', attrs = {'id' : 'harmonyContainer'}) content = '' for paragraph in div.find_all('p'): content += paragraph.get_text() return content news1 = get_news_content('https://news.v.daum.net/v/20190617073049838') print(news1) import re email_reg = re.compile(r'[\w-]+@[\w.]+\w+') email_reg.search(news1) webs = ['http://www.test.co.kr', 'https://www.test1.com', 'http://www.test.com', 'ftp://www.test.com', 'http:://www.test.com', 'htp://www.test.com', 'http://www.google.com', 'https://www.homepage.com.'] web_reg = re.compile('https?://[\w.]+\w+$') list(map(lambda w:web_reg.search(w) != None, webs)) | cs |
728x90
반응형
'Python' 카테고리의 다른 글
lambda (0) | 2019.10.26 |
---|---|
정규표현식 (0) | 2019.10.26 |
class 연산자 재정의 (0) | 2019.10.26 |
class 상속 (0) | 2019.10.26 |
class staticmethod (0) | 2019.10.26 |