ʹÓÃpython»ñÈ¡htmlÒ³ÃæµÄÄÚÈÝ
import urllib
from HTMLParser import HTMLParser
class TitleParser(HTMLParser):
def __init__(self):
self.title = ''
self.divcontent = ''
self.readingtitle = 0
self.readingdiv = 0
HTMLParser.__init__(self)
def handle_starttag(self, tag, attrs):
if tag == 'title':
self.readingtitle = 1
if -1 != tag.find("div"):
self.readingdiv = 1
def handle_data(self, data):
if self.readingtitle:
# Ordinarily, this is slow and a bad practice, but
# we can get away with it because a title is usually
# small and simple.
self.title += data
if self.readingdiv:
self.divcontent += data
def handle_endtag(self, tag):
if tag == 'title':
self.readingtitle = 0
if tag == "div":
self.readingdiv = 0
def gettitle(self):
return self.title
def getdiv(self):
return self.divcontent
def getweb(url):
web = urllib.urlopen('http://blog.chinaunix.net/u3/105068/showart_2223566.html').read()
return web
web = getweb('http://blog.chinaunix.net/u3/105068/showart_2223566.html')
test = TitleParser()
test.feed(web)
file_object = open('abinfile', 'w')
file_object.write(test.title)
file_object.write("\r\n")
file_object.write(test.divcontent)
file_object.close()
Ïà¹ØÎĵµ£º
ÉèÖÃEmacsµÄHOME,¿ÉÒÔÔÚscratch bufferÖÐÊäÈ룺(insert (getenv "HOME"))²é¿´
ÏÂÔØpython-mode.el
ÓÃEmacs´ò¿ªpython-mode.elÈ»ºóM-x byte-compile-file±àÒëpython-mode.elΪelc
C-h v²é¿´load-path±äÁ¿
ÔÚHOME/.emacs.d/init.elÖÐÌí¼Ó(setq load-path (cons "D:\\emacs-23.1-bin-i386" load-path))
½«pyÎļþÓëpytho ......
javascript ¿ØÖÆ htmlÔªËØ ÏÔʾ/Òþ²Ø
1¡£±àдjsº¯Êý
<script type="text/javascript">
function display(y){$(y).style.display=($(y).style.display=="none")?"":"none";}
function $(s){return document.getElementById(s);}
</script>
2. ÒªÏÔÊ ......
A client asked me to do something seemingly simple.
"I want the Alert to have just this one sentence bolded."
Well, it's not exactly simple, so here's how you do it:
there are two solutions as below :
import mx.core.IUITextField;
use namespace mx.core.mx_internal;
message +="Press ......
1 ËùÓÐµÄ .java|.jsp|.html|.xml Ô´Îļþ¾ùʹÓÃutf-8±àÂë¸ñʽ±£´æµ½ÏµÍ³´ÅÅÌ¡£
È磺ÔÚEclipseÖбà¼Îļþ£¬Ñ¡ÖÐÎļþ´ò¿ªÓÒ¼ü²Ëµ¥Ñ¡ÔñÊôÐÔ£¬½«Îı¾Îļþ±àÂëÉèÖÃΪÆäËû²¢Ñ¡ÔñUTF-8£»Ò²¿ÉÒÔÔÚ
Eclipse——Ê×Ñ¡Ïî——³£¹æ——ÄÚÈÝÀàÐÍÖÐÉèÖø÷ÖÖÎļþµÄȱʡ±àÂ룬ÕâÑùÒÔºóËùÓеÄÎı¾Îļþ¶¼Ê¹ÓÃÍ³Ò ......