Python httplib,smtplib使用方法
例一:使用httplib访问某个url然后获取返回的内容:
import httplib
conn=httplib.HTTPConnection("www.tingtuge.com")
conn.request("GET", "/?id=35")
r=conn.getresponse()
print r.read() #获取所有内容例二:使用smtplib发送邮件
import smtplib smtpServer = 'smtp.xxx.com' fromaddr = 'foo@xxx.com' toaddrs = 'your@xxx.com' msg = 'Subject: xxxxxxxxx' server = smtplib.SMTP(smtpServer) server.sendmail(fromaddr, toaddrs, msg) server.quit( )
