Thief of Wealth
웹크롤링 기초3. 네이버 KPI200 지수 일별 체결가 추출 (html)
개발/Financial Programming 2019. 4. 28. 18:14

'''네이버 국내주식 KPI200일자별로 시세를 나타내기html 크롤링 분석 (국내주식은 JSON로 제공x)'''def get_Max_pagenumber(code): #마지막 페이지가 어딘지 추출 return int( get_InCounty_DateNCost(code, 1)[0].find('td', class_='pgRR').find('a')['href'].split('&')[1].split('=')[1] ) def get_InCounty_DateNCost(code, page_number): #code에 따른 source, date, cost추출 url = "https://finance.naver.com/sise/sise_index_day.nhn?code="+code+"&page="+str(page_nu..

웹 크롤링 기초 2, 네이버에서 KPI200지수 얻어내기
개발/Financial Programming 2019. 4. 21. 02:04

네이버에서 KPI200지수 데이터 긁어오기를 해봅시다. # -*- coding: utf-8 -*-"""Spyder Editor This is a temporary script file.""" index_code = "KPI200" # KPI200 지수 코드입니다.page_number = 1 # 긁어올 naver 금융 중에 KPI200지수 시세입니다.naver_url = 'http://finance.naver.com/sise/sise_index_day.nhn?code=' + index_code + '&page=' + str(page_number) from urllib.request import urlopensource = urlopen(naver_url).read() # 긁어 와보리기#print(sourc..

웹 크롤링 기초 1
개발/Financial Programming 2019. 4. 21. 01:46

사이트에서 데이터를 긁어오는 소스이다. # -*- coding: utf-8 -*-"""Spyder Editor This is a temporary script file.""" from bs4 import BeautifulSoup html_doc = """The OfficeIn my office, there are four officers,YW,JK,YJ andKS....""" soup = BeautifulSoup(html_doc, 'html.parser')print(soup.prettify()) #예쁘게 출력 print(soup.title) # title tag만 출력 print(soup.find_all("a")) # a태그 가지는 것들을 list형태로 출력 # a태그 가지는 것들의 요소를 list형으로..

profile on loading

Loading...