Я пытаюсь перенести веб-форум, где у меня нет контроля над базой данных и т. Д., И использую Scrapy, чтобы собирать фрагменты.Он основан на старом форуме phpBB 2.x.Он не очень хорошо структурирован, поэтому несколько проблем.
Теперь у меня есть строка HTML, где мне нужно удалить окружающие <td></td>
, <span></span>
и ссылка на отчет внизу
Начиная с:
<td colspan="2"><span class="postbody"></span>
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="genmed"><b>Some wrote :</b></span></td>
</tr>
<tr>
<td class="quote">
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="genmed"><b>Another wrote:</b></span></td>
</tr>
<tr>
<td class="quote">Just for test
<a href="https://something.com">a link</a>
</td>
</tr>
</table>
<span class="postbody">
<br>
<br>
Test quote #1</span>
</td>
</tr>
</table>
<span class="postbody">
<br>
<br>
Test quote #2<br>
Another link: <a href="https://another.com">linktext</a><br>
_________________<br>/ author
<br>
text<br>
<div align="right">[ <a href="#" class="postlink" onclick="abuse('http://gt40.forum24.se/viewtopic.php?p=6537*6537&forum=gt40');">Rapportera</a>
] </div>
</span><span class="gensmall"></span>
</td>
Требуется результат:
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="genmed"><b>Some wrote :</b></span></td>
</tr>
<tr>
<td class="quote">
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="genmed"><b>Another wrote:</b></span></td>
</tr>
<tr>
<td class="quote">Just for test
<a href="https://something.com">a link</a>
</td>
</tr>
</table>
<span class="postbody">
<br>
<br>
Test quote #1</span>
</td>
</tr>
</table>
<br>
<br>
Test quote #2<br>
Another link: <a href="https://another.com">linktext</a><br>
_________________<br>/ author
<br>
text<br>
Любые советы?