1
嗨,我已經使用這個標籤從html文件中找到標籤的內容。如何使用python查找並從html文件中獲取文本?
def everything_between(text,begin,end):
idx1=content.find(begin)
idx2=content.find(end,idx1)
return content[idx1+len(begin):idx2].strip()
content=open('page.html').read()
title=everything_between(content,'<ul class="members">','</ul>')
interesting=everything_between(content,'INTERESTING:','bodystuff')
print(title)
但在標籤<ul class="member">
有多個<ahref>
標籤, 我想有<a href="/history/member/">
腳本應該得到<a href="/history/member/"></a>
之間的值<a href>
之間的內容。
我該怎麼做?
[使用XML解析器(http://stackoverflow.com/a/1732454/647772) – 2012-11-05 12:26:17