0
我試圖解析這個頁面 http://www.lib.uts.edu.au/about-uts-library/corporate-information/library-glossary 和得到公正的如何解析網站的詞彙部分與BeautifulSoup剝HTML標籤
標題, 說明
每個部分,這就是它,沒有標籤。 我解析頁面並嘗試搜索所有<title>
和<p>
標記,但它不會產生正確的結果。
我使用Python 2.7和BeautifulSoup 3-2-0
這裏是我的代碼示例:
import urllib2, sys
address = sys.argv[1]
html = urlib2.urlopen(http://www.lib.uts.edu.au/about-uts-library/corporate-information/library-glossary).read()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(html)
def printText(tags):
for tag in tags:
if tag._class_==NavigableString:
print tag,
else:
printText(tag)
print ""
printText(soup.findALL("p"))
print "".join(soup.findALL("p", text=re.compile(".")))