我试图获取<h2>
和</h2>
之间的所有内容。像这样的:使用beatifulsoup在标签之间获取内容
<h2> Header 1 </h2>
This is an example text for <a href="https://example.com">site</a>
Any HTML-Code can appear
<br />
<p>
<h2> Header 2 </h2>
Some other text with no tags
<h2> Header 3 </h2>
的结果应该是:
This is an example text for <a href="https://example.com">site</a>
Any HTML-Code can appear
<br>
<p>
和:
Some other text with no tags
谁能把我推在正确的方向?
你能得到整个文字,然后用分解()取本H2标签? – RoundFour
到目前为止你有尝试过什么吗? – Nobita
鉴于你在下面陈述,你的问题有点不清楚。我不明白你是在寻找仅在两个标签之间的文本,或者你想保留''和'
'标签以及文本 – DMPierre