我有以下格式的html文件。我想用python解析它。但是,我對使用xml模塊一無所知。您的建議非常受歡迎。使用Python解析HTML文件:起點
注意:對不起,我再無知。問題不是特定的。然而,由於我對這樣的解析腳本感到沮喪,我確實想得到一個由答案人(謝謝大家)描述的具體答案作爲出發點。希望你能理解。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Weibo Landscape: Historical Archive of 800 Verified Accounts</title>
</head>
<body>
<div><br>
related 1-th-weibo:<br>
mid:3365546399651413<br>
score:-5.76427445942 <br>
uid:1893278624 <br>
link:<a href="http://weibo.com/1893278624/xrv9ZEuLX" target="_blank">source</a> <br>
time:Thu Oct 06 17:10:59 +0800 2011 <br>
content: Zuccotti Park。 <br>
<br></div>
<div><br>
related 2-th-weibo:<br>
mid:3366839418074456<br>
score:-5.80535767804 <br>
uid:1813080181 <br>
link:<a href="http://weibo.com/1813080181/xs2NvxSxa" target="_blank">source</a> <br>
time:Mon Oct 10 06:48:53 +0800 2011 <br>
content:rt the tweet <br>
rtMid:3366833975690765 <br>
rtUid:1893801487 <br>
rtContent:#ows#here is the content and the link http://t.cn/aFLBgr <br>
<br></div>
</body>
</html>
關於用Python解析HTML有很多問題。請花幾分鐘時間尋找。在上面鏈接的問題中,請參閱使用'HTMLParser'的示例 –
當然。我搜查過了,這不是我想要的。我希望結果更具結構性,而不是將其轉換爲文本。 –
這只是一個例子 - 關於HTML解析有幾個Q和As:http://stackoverflow.com/search?q=python%20html%20parse –