목록crawling (3)
gyeomii
1. 자바프로젝트 생성 자바에서 Spring boot 프로젝트를 생성한다. maven으로 생성했다. 2. Dependency 추가 자바에서 selenium을 사용하기 위해 selenium dependency를 추가한다. org.seleniumhq.selenium selenium-java 3.141.59 3. chrome 드라이버 다운로드 자신의 chrome 버전에 맞는 드라이버를 설치한다. 크롬창 -> 설정 -> Chrome정보 -> 버전확인 )) 크롬 드라이버 다운로드 페이지 크롬 드라이버 다운로드 페이지에 가서 자신의 크롬버전과 맞는 드라이버를 다운로드한다. 현재 최신버전은 114버전이지만 현재 크롬버전은 116이기에 Test버전을 다운받는다. (114버전드라이버를 사용해도 작동하긴한다.) )) 복사..
1분마다 .py실행해서 DB에 자료 저장하기 코드 import requests from datetime import datetime from bs4 import BeautifulSoup from stockdao import StockDao sd = StockDao() ymd = datetime.today().strftime("%Y%m%d.%H%M") url = "https://vip.mk.co.kr/newSt/rate/item_all.php" response = requests.get(url) if response.status_code == 200: html = response.content.decode('euc-kr','replace') soup = BeautifulSoup(html, 'html.par..
매일경제 주식 시세 사이트 크롤링하기 코드 import requests from bs4 import BeautifulSoup url = "https://vip.mk.co.kr/newSt/rate/item_all.php" response = requests.get(url) if response.status_code == 200: html = response.content.decode('euc-kr','replace') soup = BeautifulSoup(html, 'html.parser') attr1 = {'class' : 'st2', 'width' : '92'} tds = soup.find_all('td', attrs = attr1) #attr2 = {'width':'60'} #price = soup...