• 运行成功


    # -*- coding: utf-8 -*-
    
    from selenium import webdriver
    from time import sleep
    from email.mime.text import MIMEText
    from email.header import Header
    from email.mime.multipart import MIMEMultipart
    from email.mime.application import MIMEApplication
    
    options = webdriver.ChromeOptions()
    prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'C:/Users/fxia/Desktop/shiftplan'}
    options.add_experimental_option('prefs', prefs)
    
    driver = webdriver.Chrome(executable_path='C:/Users/fxia/Downloads/chromedriver_win32/chromedriver.exe', chrome_options=options)
    driver.get('http://workit.nnitcorp.com/Departments/086-0961/Middleware/Shared%20Documents/Teamet/Shiftplan24_7_v1.xls')
    #driver.find_element_by_xpath('C:/Users/fxia/Desktop/shiftplan/a[text()="testsaveas.zip"]').click()
    sleep(3)
    driver.quit()
    
    
    
    ###########
    import win32com.client as win32
    import xlrd
    import time
    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    receivers = ['4422@qq.com']
    mail.To = receivers[0]
    #day = time.strftime("%d/%m/%Y")
    mail.Subject ='shiftplan'
    workbook = xlrd.open_workbook('C:/Users/fxia/Desktop/shiftplan/Shiftplan24_7_v1.xls')
    mySheet = workbook.sheet_by_index(0)
     
    nrows = mySheet.nrows
    ##################
    mail.body=('''
    this is a test
    <br>/n</br>
    test2
    ''')
    
    #######################
    mail.Attachments.Add('C:/Users/fxia/Desktop/shiftplan/Shiftplan24_7_v1.xls')
    mail.Send()
    
    ###
    sleep(30)
    
    
    import os
    my_file = 'C:/Users/fxia/Desktop/shiftplan/Shiftplan24_7_v1.xls'
    if os.path.exists(my_file):
        #删除文件,可使用以下两种方法。
        #os.remove(my_file)
        os.unlink(my_file)
    else:
        print ('no such file:%s'%my_file)
    
  • 相关阅读:
    用jQuery开发插件详解
    position:absolute和float会隐式的改变display类型
    链家H5项目总结
    jQuery中的选择器
    jqeury实现全选和反选
    $.extend(),与$.fn.extend() 讲解(一)
    mybatis用distinct进行查询的问题
    mybatis 动态Sql的模糊查询
    mysql
    @RequestParam和@PathVariable的区别
  • 原文地址:https://www.cnblogs.com/latefall/p/9677955.html
Copyright © 2020-2023  润新知