반응형
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 | 31 |
Tags
- msSQL
- Docker
- incr
- 이분탐색
- dfs
- 성적평가
- 6987
- softeer
- Kafka
- boj #19237 #어른 상어
- BFS
- 처우협의
- 백트래킹
- 매개변수탐색
- upper_bound
- 연결요소
- OFFSET
- @P0
- 소프티어
- 퇴사통보
- 13908
- 경력
- 파라메트릭
- BOJ
- 백준
- 처우산정
- 물채우기
- 오퍼레터
- compose
- 기술면접
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 |