ich einige Codes von einer Webseite zu extrahieren (http://www.opensolaris.org/os/community/on/flag-days/all/) wie folgt,Wie eine relative URL zu finden und es auf eine absolute URL in Python übersetzen
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td></td>
<td></td>
<td>
<a href="../pages/2009022501/">Flag Day and Heads Up: Power Aware Dispatcher and Deep C-States</a><br />
cpupm keyword mode extensions - <a href="/os/community/arc/caselog/2008/777/">PSARC/2008/777</a><br />
CPU Deep Idle Keyword - <a href="/os/community/arc/caselog/2008/663/">PSARC/2008/663</a><br />
</td>
</tr>
und es gibt einige relativen Pfade url darin, jetzt Ich möchte es mit regulärem Ausdruck suchen und sie durch absoluten URL-Pfad ersetzen. Da ich weiß, urljoin kann die Arbeit so ersetzen tun,
>>> urljoin("http://www.opensolaris.org/os/community/on/flag-days/all/",
... "/os/community/arc/caselog/2008/777/")
'http://www.opensolaris.org/os/community/arc/caselog/2008/777/'
Jetzt möchte ich wissen, dass, wie sie mit regulären Ausdrücken zu suchen, und tanslate schließlich den Code,
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td></td>
<td></td>
<td>
<a href="http://www.opensolaris.org/os/community/on/flag-days/all//pages/2009022501/">Flag Day and Heads Up: Power Aware Dispatcher and Deep C-States</a><br />
cpupm keyword mode extensions - <a href="http://www.opensolaris.org/os/community/arc/caselog/2008/777/">PSARC/2008/777</a><br />
CPU Deep Idle Keyword - <a href="http://www.opensolaris.org/os/community/arc/caselog/2008/663/">PSARC/2008/663</a><br />
</td>
</tr>
Mein Wissen über Reguläre Ausdrücke sind so schlecht, dass ich wissen möchte, wie das geht. Danke
Ich habe die Arbeit mit Beautiful Soup beendet, haha ~ Thx für alle!
Und es ist ein Duplikat: http://stackoverflow.com/questions/442660/link-extraction-in-python-closed –