网络编程
位置:首页>> 网络编程>> Python编程>> Python httplib,smtplib使用方法

Python httplib,smtplib使用方法

  发布时间:2021-12-23 04:34:29 

标签:Python,httplib,smtplib

例一:使用httplib访问某个url然后获取返回的内容:

Python httplib,smtplib使用方法import httplib
Python httplib,smtplib使用方法
Python httplib,smtplib使用方法conn=httplib.HTTPConnection("www.cnblogs.com")
Python httplib,smtplib使用方法conn.request("GET", "/coderzh/archive/2008/05/13/1194445.html")
Python httplib,smtplib使用方法r=conn.getresponse()
Python httplib,smtplib使用方法print r.read() #获取所有内容


例二:使用smtplib发送邮件

Python httplib,smtplib使用方法import smtplib
Python httplib,smtplib使用方法smtpServer = 'smtp.xxx.com'
Python httplib,smtplib使用方法fromaddr = 'foo@xxx.com'
Python httplib,smtplib使用方法toaddrs = 'your@xxx.com'
Python httplib,smtplib使用方法msg = 'Subject: xxxxxxxxx'
Python httplib,smtplib使用方法server = smtplib.SMTP(smtpServer)
Python httplib,smtplib使用方法server.sendmail(fromaddr, toaddrs, msg)
Python httplib,smtplib使用方法server.quit( )

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com