커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
강의에서 알려주신 해당코드 대로 해봤는데 오류가 생깁니다.
undefined주차
북마크
조*기
댓글
2
추천
0
조회수
19
조회수
19
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


강의에서 알려주신 해당코드 대로 해봤는데 오류가 생깁니다.



스파르타 즉문즉답




작성한 코드 및 에러 메세지

아래가 작성한 코드구요


import requests

from bs4 import BeautifulSoup


headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}

data = requests.get('https://search.naver.com/search.naver?where=news&ie=utf8&sm=nws_hty&query=삼성전자',headers=headers)


soup = BeautifulSoup(data.text, 'html.parser')


a= soup.slect_one('#sp_nws_all1 > div.news_wrap.api_ani_send > div > a')






아래 텍스트 가 에러가 뜨는 메시지입니다.


Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: bs4 in /usr/local/lib/python3.8/dist-packages (0.0.1)
Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (2.23.0)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.8/dist-packages (from bs4) (4.6.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests) (2022.9.24)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests) (1.24.3)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/dist-packages (from requests) (3.0.4)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-73-98b319c5daea> in <module>
      9 soup = BeautifulSoup(data.text, 'html.parser')
     10 
---> 11 a= soup.slect_one('#sp_nws_all1 > div.news_wrap.api_ani_send > div > a')
     12 
     13 a.text

TypeError: 'NoneType' object is not callable





취소
 공유
취소
댓글 0
댓글 알림
나의얼굴