카테고리 없음
[ 크롤링 ] NotImplementedError: Only the following pseudo-classes 해결방법
취미와 밥줄사이
2021. 6. 15. 15:05
에러 문구
NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.
작성코드
import requests
from bs4 import BeautifulSoup
url = 'https://kin.naver.com/search/list.nhn?query=%ED%8C%8C%EC%9D%B4%EC%8D%AC'
response = requests.get(url=url)
if response.status_code == 200:
html = response.text
soup = BeautifulSoup(markup=html, features='html.parser')
title = soup.select_one(selector='#s_content > div.section > ul > li:nth-child(1) > dl > dt > a')
print(title)
else :
print(response.status_code)
해결 방법
- 코드를 아래와 같이 수정한다.
li:nth-child(1) -------> li:nth-of-type(1)
elenium을 기반으로 한 BeautifulSoup에서는 nth-child 선택자를 지원하지 않는다고 한다. nth-child 선택자 대신 nth-of-type을 사용하면 됩니다
인용: https://codedragon.tistory.com/10474
REFERENCE
https://mjdeeplearning.tistory.com/46
Python 크롤링 시 Only the following pseudo-classes are implemented: nth-of-type.오류
Only the following pseudo-classes are implemented: nth-of-type.selenium 구글 크롬 개발자도구에서 셀렉터 카피에서 나오는 child 선택자인 nth-child 를 지원하지 않는다. tr:nth ->nth-of-type 으로 바꿔준..
mjdeeplearning.tistory.com
https://codedragon.tistory.com/10474
NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type. 오류메시지, 해결방법
오류 메시지 {BequtifulSoap}에서 n번째에 위치하는 문서 객체를 선택할 경우 아래와 같은 오류메시지가 발생합니다. NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type. 해..
codedragon.tistory.com
위키독스
온라인 책을 제작 공유하는 플랫폼 서비스
wikidocs.net