Skip to content

Instantly share code, notes, and snippets.

@hyunsikhwang
Last active August 16, 2017 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyunsikhwang/720e1474f8759399e762fb3056027c31 to your computer and use it in GitHub Desktop.
Save hyunsikhwang/720e1474f8759399e762fb3056027c31 to your computer and use it in GitHub Desktop.
P2P 투자 펀다 사이트에서 투자정보를 파싱하는 방법
import bs4, requests
def get_beautiful_soup(url):
return bs4.BeautifulSoup(requests.get(url).text, "html5lib")
soup = get_beautiful_soup('https://www.funda.kr/v2/investment')
#print(soup.prettify())
pkg_list = soup.find_all("div", "merchandise_inner_box")
pkg_details = soup.find_all("div", "merchandise_details")
progress = soup.find_all("div", "merchandise_progress_bar")
idx = 0
m_title = []
m_dtls = []
m_name = []
for i in pkg_list:
title = i.find_all('span')
m_list = title[0].text
m_title.append(m_list)
for i in pkg_details:
details = i.find_all('span')
m_details = details[1].text.replace(" ", "").replace('\n','').replace('\r','')
#m_dtls.append(m_title[idx] + " / " + m_details)
m_dtls.append(m_title[idx])
idx=idx+1
idx = 0
for i in progress:
#amt = i.find_all("span", "pull-left")
#m_list = amt[0].text
ratio = i.find_all("span", "pull-right")
m_list = ratio[0].text.replace('\n','').replace('\r','')
if m_list != '100%':
m_name.append(m_dtls[idx] + " / " + m_list)
idx=idx+1
for i in m_name:
print(i)
print("-------------------------------------")
#for i in range(0,count):
# print(m_name)
# See: http://www.crummy.com/software/BeautifulSoup/bs4/doc for all the things you can do with the soup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment