스크래핑 4

파이썬(Python) - 크롤링 연습 ② 국민 청원 청원 목록 수집(추천순)

# 국민 청원 접속 및 청원 목록 url 수집 url = [] for i in range(1,21): html = urlopen("https://www1.president.go.kr/petitions/best?page={}".format(i)) soup = BeautifulSoup(html,'html.parser') for j in soup.findAll('div',{'class':'bl_body'}): for k in j.findAll('div',{'class':'bl_subject'}): a = k.find('a')['href'] if bool(re.match('/[a-z].*/[0-9].*\?navigation=best',a)): url.append(a) # 청원 제목 수집 title = [] fo..

파이썬(Python) - 크롤링 연습 ① 사람인 빅데이터 채용 조건 수집

1. 채용 조건 wordcloud로 만들기 browser = webdriver.Chrome('C:/chromedriver.exe') browser.get("http://www.saramin.co.kr/zf_user/search/recruit?search_area=main&search_done=y&search_optional_item=n&searchType=search&searchword=%EB%B9%85%EB%8D%B0%EC%9D%B4%ED%84%B0&recruitPage=1") time.sleep(3) soup = BeautifulSoup(browser.page_source,'html.parser') job = [] for i in soup.findAll('div',class_='item_recruit..

파이썬(Python) - 스크래핑 ② 웹 스크래핑/크롤링 연습, wordcloud사용

기본 용어 http(hyper text transfer protocol) hyper text는 마우스로 클릭하면 다른페이지로 이동하는 기능 http는 다음에 나올 html로 작성되어 있는 hyper text를 전송하기 위한 프로토콜(규약, 약속) URL(Uniform Resource Locator) 인터넷 주소 HTML(Hyper Text Markup Language) 웹페이지를 작성하는 문법 언어 F12(개발자 도구)눌러서 볼수 있다. 웹 브라우저(web browser) html을 보기 좋게 출력하는 응용 소프트웨어 웹 스크래핑 연습 BeautifulSoup 데이터를 추출하는데 필요한 기능이 들어 있는 라이브러리, 파싱(parsing)라이브러리 라고도 한다. 파싱은 받아온 데이터에서 필요한 내용만 추출..

파이썬(Python) - 스크래핑 ① 스크래핑 기초

스크래핑(scraping) 컴퓨터 프로그램이 다른 프로그램으로부터 들어오는 인간이 읽을 수 있는 출력으로부터 데이터를 추출하는 기법이다. BeautifulSoup 데이터를 추출하는데 필요한 기능이 들어 있는 라이브러리, 파싱(parsing)라이브러리 라고도 한다. 파싱은 받아온 데이터에서 필요한 내용만 추출하는 것을 의미한다. from bs4 import BeautifulSoup 예제 1) html = """ 동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라만세 """ # BeautifulSoup 객체 생성 soup = BeautifulSoup(html, "html.parser") soup # BeautifulSoup 객체의 html -> body -> h1 태그 출력 h1 = soup.html..

반응형