-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
13분 16초 li:nth-of-type(8) 질문
19.10.12 16:27 작성 조회수 156
0
입력한 코드
from bs4 import BeautifulSoup
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
fp = open("food-list.html", encoding="utf-8")
soup = BeautifulSoup(fp, "html.parser")
print("1",soup.select_one("li:nth-of-type(8)").string)
에러
Traceback (most recent call last): File "C:\Users\User0\Desktop\code\section2\download2-6-2.py", line 25, in <module> print("1",soup.select_one("li:nth-of-type(8)").string) AttributeError: 'NoneType' object has no attribute 'string'
[Finished in 0.181s]
이렇게 에러나면서 실행이 안되는데 어떤문제때문에 안되는건가요??
답변을 작성해보세요.
0
좋은사람
지식공유자2019.10.14
안녕하세요.
해당 예제는 공지 보시면 새로운 예제 소스코드로 변경해서 올렸습니다.
https://github.com/eunki7/python_create_app_1/blob/master/section2/2-6-2_new_1.py
2-6-2_new 입니다.
위에 링크 확인 부탁드려요!
답변 1