先看下定时执行的py文件
#coding:gbk from selenium import webdriver import time,os driver = webdriver.PhantomJS() #chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" #调用chrome安装文件夹下的驱动文件(驱动需要下载) #os.environ["webdriver.chrome.driver"] = chromedriver #driver = webdriver.Chrome(chromedriver) driver.get('http://passport.cnblogs.com/user/signin') driver.find_element_by_id("input1").send_keys('name*****') driver.find_element_by_id("input2").send_keys('password****') driver.find_element_by_id("signin").click() print 'logining' time.sleep(3) driver.get('http://i.cnblogs.com/Configure.aspx') time.sleep(3) head2_title=u'<a id="Header2_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/hito/">学如逆水行舟,不进则退</a>' driver.find_element_by_id("Edit_txbSubtitle").clear() driver.find_element_by_id("Edit_txbSubtitle").send_keys(head2_title) edit_css=u'#Header2_HeaderTitle{font-size: 120%;font-weight: bold;line-height: 1.5em;font-family: "微软雅黑", "verdana","ms song","宋体","Arial","Helvetica", "sans-serif";margin: 0;padding: 0;color: white;}' driver.find_element_by_id("Edit_txbSecondaryCss").clear() driver.find_element_by_id("Edit_txbSecondaryCss").send_keys(edit_css) driver.find_element_by_id("Edit_lkbPost").click() driver.quit() print 'OK'
写这个的原因呢是因为副标题的Id和css每天都会自动变化,导致博客园样式走样,所以直接执行这个文件就可以了
windows定时计划设置
控制面板-->管理工具-->任务计划程序-->创建任务
设置名称,触发器tab中设置任务触发条件及定时参数的设定,操作tab中直接引用py文件,其他设置根据提示设定