python實例-網站標題的抓取

 #vi a.py
import urllib,urllib2,cookielib
import re
print "輸入網址:"
input_url='http://' + raw_input()
html_ urllib.urlopen(input_url).read()
#print html_src
re_bt="<title>.*</title>"
m=re.search(re_bt,html_src)
print m.group().strip("</title>")
#python a.py
www.scpman.com #輸入網址
論壇 - Scpman's BBS #程序返回標題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章