정규표현식2 [pyhon] 웹 크롤러[정규표현식] #이미지다운 [웹 크롤러 만들기] import requests import urllib.request import re # [img 태그] URL = 'https://www.daum.net/' headers = {'Content-Type': 'application/json; charset=utf-8'} res = requests.get(URL, headers=headers) html = res.text re_img = re.compile("]+>", re.MULTILINE) img_tag = re_img.findall(html) # [src 속성] re_src = re.compile("[Ss][Rr][Cc][^\s]+", re.MULTILINE) img_src = re_src.findall('\n'.join(img_.. 2018. 8. 24. [pyhon] 웹 크롤러[정규표현식] #a태그 [웹 크롤러 만들기] import requests import re # [a 태그] URL='https://www.daum.net/' headers = {'Content-Type': 'application/json; charset=utf-8'} res=requests.get(URL,headers=headers) html=res.text re_a = re.compile("]+>", re.MULTILINE) a_tag = re_a.findall(html) print('\n'.join(a_tag)) [python] requests 모듈 정리 2018. 8. 24. 이전 1 다음