get text after specific tag with beautiful soup

前端 未结 1 810
[愿得一人]
[愿得一人] 2020-12-06 01:55

I have a text like

page.content = \"Title: Test title\"

I can get the Title tag with



        
相关标签:
1条回答
  • 2020-12-06 02:38

    Referring to the docs you might want to use the next_sibling of your b_el:

    b_el.next_sibling    # contains " Test title"
    

    "Sibling" in this context is the next node, not the next element/tag. Your element's next node is a text node, so you get the text you want.

    0 讨论(0)
提交回复
热议问题