2008年6月23日 星期一

Auto-Post@Python

想把電腦裡的Vmware Server版移除掉了
主要是現在使用Linux的時間越來越少
而現在Linux存在電腦裡的價值也只有掛Auto-Post的bot

最近深深的覺得.NET和Python的好用
之前從SATURN那拿到PHP版的fetch bot
而PHP執行的效率實在有些低落
剛好最近在學習Python
就順勢的將程式用Python重寫過摟
也為將來在XP上執行打底
不過碰到了一些問題
將其列在下面摟
PHP file_get_contents->Python
def file_get_contents(URL):
filehandle = urllib.urlopen(URL, proxies=proxies)
str=""
for content in filehandle:
str+=content
return str

PHP strip_tags->Python
def strip_tags(value):
#http://smitbones.blogspot.com/2008/01/python-strip-html-tags-function.html
#"Return the given HTML with all tags stripped."
return re.sub(r'<[^>]*?>', '', value)

PHP mail->Python
def mail(serverURL=None, sender='', to='', subject='', text=''):
#http://www.eskimo.com/~jet/python/examples/mail/smtp1.html
#"""
#Usage:
#mail('somemailserver.com', 'me@example.com', 'someone@example.com', 'test', 'This is a test')
#"""
headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (sender, to, subject)
message = headers + text
mailServer = smtplib.SMTP(serverURL)
mailServer.sendmail(sender, to, message)
mailServer.quit()

Python寄信Subject編碼不正確問題
title="=?big5?B?"+base64.b64encode(title)+"?="

0 意見: