beautifulsoup查找唯一的div标签

时间:2019-09-12 17:14:25

标签: beautifulsoup

使用bs4。尝试在<div data-reactroot>中查找html信息时,我永远无法找到它。在<div data-reactroot>内部,我将不得不遍历每个文本条目并将其拆分。我知道如何找到普通标签,但是data-reactroot似乎给我带来了很多麻烦。

<div data-reactroot="">
   <div>
      <div class="_hgs47m">
         <div class="_1thk0tsb">
            <div style="margin-right:8px">
               <div class="_1ciyl4o"><span class="_8tbpu3" aria-hidden="true">?</span></div>
            </div>
         </div>
         <div class="_n5lh69r">
            <div class="_1p3joamp">Entire guest suite</div>
            <div class="_36rlri">
               <div class="_36rlri" style="margin-right:24px">
                  <div class="_czm8crp">2 guests</div>
               </div>
               <div class="_36rlri" style="margin-right:24px">
                  <div class="_czm8crp">1 bedroom</div>
               </div>
               <div class="_36rlri" style="margin-right:24px">
                  <div class="_czm8crp">1 bed</div>
               </div>
               <div class="_36rlri" style="margin-right:0">
                  <div class="_czm8crp">1 bath</div>
               </div>
            </div>
         </div>
      </div>
      <div style="margin-top:16px">
         <div class="_hgs47m">
            <div class="_1thk0tsb">
               <div style="margin-right:8px">
                  <div class="_1ciyl4o"><span class="_8tbpu3" aria-hidden="true">?</span></div>
               </div>
            </div>
            <div class="_n5lh69r">
               <div><span class="_1p3joamp">Self check-in</span></div>
               <div class="_czm8crp">Check yourself in with the keypad.</div>
            </div>
         </div>
      </div>
      <div style="margin-top:16px">
         <div class="_hgs47m">
            <div class="_1thk0tsb">
               <div style="margin-right:8px">
                  <div class="_1ciyl4o"><span class="_8tbpu3" aria-hidden="true">?</span></div>
               </div>
            </div>
            <div class="_n5lh69r">
               <div><span class="_1p3joamp">Sparkling clean</span></div>
               <div class="_czm8crp">9 recent guests said this place was sparkling clean.</div>
            </div>
         </div>
      </div>
      <div style="margin-top:16px">
         <div class="_hgs47m">
            <div class="_1thk0tsb">
               <div style="margin-right:8px">
                  <div class="_1ciyl4o"><span class="_8tbpu3" aria-hidden="true">?</span></div>
               </div>
            </div>
            <div class="_n5lh69r">
               <div><span class="_1p3joamp">Michael &amp; Tammy is a Superhost</span></div>
               <div class="_czm8crp">Superhosts are experienced, highly rated hosts who are committed to providing great stays for guests.</div>
            </div>
         </div>
      </div>
      <div style="margin-top:24px;margin-bottom:24px">
         <div class="_7qp4lh"></div>
      </div>
   </div>
</div>

我尝试过

data_soup.find_all("div data-reactroot")

data_soup.get('data-reactroot')

0 个答案:

没有答案