인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

as2835510547's profile image
as2835510547

asked

Introduction to Python and Creating Various Automated Applications Using Web Crawling

How to use BeautifulSoup and basic simple web parsing (2)

atom과 jupyter notboook 결과가 다르네요

Written on

·

115

0

fp ='''

안주 및 주류

  • 닭도리탕
  • 돈까스
  • 삼겹살
  • 스테이크

  • 소주
  • 맥주
  • 막걸리
  • 양주
  • 동동주

'''

atom에서 실행하면,

print("1",soup.select_one("li:nth-of-type(1)").string) #-> 결과값 닭도리탕

print("2",soup.select_one("li:nth-of-type(2)").string) #->돈까스

print("3",soup.select_one("li:nth-of-type(3)").string) #->삼겹살

print("4",soup.select_one("li:nth-of-type(4)").string) #->스테이크

print("5",soup.select_one("li:nth-of-type(5)").string) #->동동주

print("6",soup.select_one("li:nth-of-type(6)")) #->None

print("7",soup.select_one("li:nth-of-type(7)")) #->None

jupyter notemook에서 실행하면,

선생님께서 가르쳐주신 것처럼 순서대로 나옵니다.

코드가 서로 다른 것도 아니고..

그대로 복사 붙여넣기 한건데 다르게 결과값이 나올 수 있나요..?

python웹-크롤링

Answer 1

0

niceman님의 프로필 이미지
niceman
Instructor

쥬피터 노트북에서 정확한 html 전체를 인식하지 못한것같은데요?

그래서 마지막에 6, 7번은 None이라고 나온것같습니다.

코드의 결과는 툴에 따라서 달라지지 않습니다.

노트북의 실행 영역을 확인해보셔야 될 것같네요.

as2835510547's profile image
as2835510547

asked

Ask a question