使用httplib访问某个url然后获取返回的内容和使用smtplib发送邮件的脚本实例代码例一:使用httplib访问某个url然后获取返回的内容:
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
import httplibconn=httplib.HTTPConnection("www.cnblogs.com")conn.request("GET","/coderzh/archive/2008/05/13/1194445.html")r=conn.getresponse() print r.read()#获取所有内容例二:使用smtplib发送邮件Python 3.14.3微软官方的 Python 扩展,是 VS Code 安装量最高的扩展(209M+)。集成 IntelliSense(通过 Pylance)、调试(通过 Python Debugger)、代码检查、格式化、重构和单元测试等功能。支持 Jupyter Notebook、虚拟环境管理和多 Python 版本切换。
下载
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
import smtplibsmtpServer='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( )
