저는 파이썬에 익숙합니다.BS4 + Python3 : 'NavigableString'개체에 'has_attr'속성이 없습니다.
Heres는 내 코드
내가하고 싶은 것은 속성 "확인해"만 세부 사항 (HREF 및 .string)를 얻을 수있다<h1 class="entry-title">
<a href="test1.html">test1</a></h1>
<h1 class="entry-title">
<a href="test2.html" rel="bookmark">test2</a></h1>
:
여기에 내가 함께 연습하고 간단한 운동이다
for h1_Tag in soup.find_all(("h1", { "class" : "entry-title" })):
for a_Tag in h1_Tag.contents:
if a_Tag.has_attr('rel'):
print (a_Tag)
AttributeError : 'NavigableString'객체에 'has_attr'속성이 없습니다.
내가 뭘 잘못하고 있니? 도움을 주시면 감사하겠습니다.
감사합니다.
고맙습니다! 이 작품 –