python BeautifulSoup



  • Upon request:

    print(soup.find('div', 'b-comment__user'))
    

    produces such a result

    <div class="b-comment__user">
    <a href="http://pikabu.ru/profile/EndlessSpace"><span class="">EndlessSpace</span></a>
    <span>отправлено</span>
    <time class="b-comment__time" datetime="1347413239">1215 дней назад</time>
    </div>
    

    And what kind of team should be to give only: EndlessSpace?



  • Use the method. .select♪ It allows for the search of elements with the help of the CSS-designators.

    print([e.string for e in soup.select("div.b-comment__user a span")])
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2