개발일지#3

­최상언·2020년 2월 24일
0

1. 한것

드디어 db 완성(해가는중!)

  • 페이지마다 재료 탭이 (주재료) 단일 또는 (주재료/양념)로 나뉨. 따라서 전부 나뉜다고 가정하고 크롤링 함
ingredients = list(soup.select('#divConfirmedMaterialArea > ul:nth-child(1) > li'))
spices = list(soup.select('#divConfirmedMaterialArea > ul:nth-child(2) > li'))
  • 양념 탭이 따로 없는 경우 주재료에 포함되어 있으므로, 양념 탭을 먼저 크롤링하는데 이 때 재료별로 카운트해줌
sps = {}
for s in range(len(spices)):
	spice = spices[s].text.strip().split('\n')[0].strip()
    if len(spice.split(' ')) < 3 and len(spice.split('(')) < 2:
    	spice = spice.replace(' ','')
    elif len(spice.split('(')) == 2:
    	spice = spice.split('(')[0].replace(' ','')
    else:
    	continue;
    if spice in sps:
    	sps[spice] += 1
    else:
    	sps[spice] = 1
  • 잘못 표기된 경우를 배제하기 위해 15번 이하로 나오는 항목은 빼고 spice 타입으로 db에 저장
realspice = []
for spice in sps:
    if sps[spice] >= 15:
        realspice.append(spice)

for spice in realspice:
    spice_doc = {
        'type':'spice',
        'name':spice
    }
    print(spice_doc)
    db.ingredients.insert_one(spice_doc)
  • 튕길 수 있으므로 for문 마지막에 time.sleep() 붙여줘야 함!

  • 모은 양념재료 리스트에 없는 재료를, 마찬가지로 카운트하고 적당한 개수 이상으로 걸러서 ingredient 타입으로 db에 저장

elements = ingredients + spices
if list(db.ingredients.find({'type': 'spice', 'name': element})) == []:  # spice 목록에 없으면
	if element in igt:
    	igt[element] += 1
    else:
    	igt[element] = 1
  • 유효한 것만 spice / ingredient 로 타입 나누어서 저장됨

  • 메뉴는 url과 주재료 / 양념 나누어서 저장. (여기도 유효한 재료 거르면?)

html 두번째 페이지

  • 슬라이드 형식으로 하고싶은데,,, bootstrap에서 가져온 건 세부 사항 수정하기가 힘듦. 다 하고 꾸며야지 ㅠ

2. 고민

  • 선택당한(?) 체크박스 어떻게 모을 것인지?
  • 레시피보기 창 위에 퍼센트게이지(?) 혹은 선택한 재료를 모아서 보여주고 싶음
  • 페이지마다 위에 홈버튼(로고?) 붙이고 싶음!

3. 할것

  • db에 서버, 클라이언트 연결해서 첫 번째 화면에 메뉴 체크박스 만들기
  • 체크한 항목을 바탕으로 가능한 레시피 추천하는 API !
  • css 꾸미기
profile
배울게 많은 햇병아리 개발자

0개의 댓글