我對html不太瞭解...... 如何從頁面中刪除文本? 例如,如果HTML頁面讀取爲:處理HTML文件Python
<meta name="title" content="How can I make money at home online? No gimmacks please? - Yahoo! Answers">
<title>How can I make money at home online? No gimmicks please? - Yahoo! Answers</title>
我只是想提取此。
How can I make money at home online? No gimmicks please? - Yahoo! Answers
我重新使用功能:
def striphtml(data):
p = re.compile(r'<.*?>')
return p.sub(' ',data)
但仍沒有做什麼,我想讓它做..?
上述功能被稱爲:
for lines in filehandle.readlines():
#k = str(section[6].strip())
myFile.write(lines)
lines = striphtml(lines)
content.append(lines)
可能重複http://stackoverflow.com/questions/717541/parsing-html-in- python),[使用Python處理HTML文件](http://stackoverflow.com/q/7694637) – Sathya 2012-01-09 02:45:43
檢查此問題:http://stackoverflow.com/questions/328356/extracting-text-from-html-file - 使用的Python – mgibsonbr 2012-01-09 02:47:15