이 없습니다 나는 문제는 내가 아래 오류가 유지되지 수있다 onlineAttributeError는 'NoneType'개체가 어떤 속성 '스트립'나는 파이썬 (현재 beautifulsoup4 요청하고) 배우려고 노력했습니다
튜토리얼을 발견 그것을 전부 알아 내십시오 ...
어떤 도움을 주실 수 있나요?
역 추적 (마지막으로 가장 최근 통화) : 파일 : 제목에 "C \ 사용자 \ BILLYBOB \ 바탕 화면 \ 웹 Scrap.py", 라인 14 = a.string.strip() AttributeError : 'NoneType' 객체에 'strip'속성이 없습니다.
여기는 실수 한 경우의 코드입니다. BS4 documentation에서
import requests
from bs4 import BeautifulSoup
result = requests.get("http://www.oreilly.com/")
c = result.content
soup = BeautifulSoup(c, "html.parser")
samples = soup.find_all("a")
samples[0]
data = {}
for a in samples:
title = a.string.strip()
data[title] = a.attrs['href']
'a'의'string' 속성은'None'입니다. BeautifulSoup에 대한 문서를 살펴보고'.find_all()'이 반환하는 것을 볼 필요가있다. –