新增近三日涨跌幅度提示
新增自动发送邮件功能
爬取基金估值并自动计算收益,发送数据给指定邮箱
将数据储存在本地后进行数据分析计算收益率等数据
数据库:
运行代码生成基金.csv:
import json
import re
import time
import requests
from bs4 import BeautifulSoup
import csv
import datetime
import tkinter
#from tkinter import messagebox
import smtplib
from email.mime.text import MIMEText
def Caltime(date1,date2):
#%Y-%m-%d为日期格式,其中的-可以用其他代替或者不写,但是要统一,同理后面的时分秒也一样;可以只计算日期,不计算时间。
#date1=time.strptime(date1,"%Y-%m-%d %H:%M:%S")
#date2=time.strptime(date2,"%Y-%m-%d %H:%M:%S")
date1=time.strptime(date1,"%Y-%m-%d")
date2=time.strptime(date2,"%Y-%m-%d")
#根据上面需要计算日期还是日期时间,来确定需要几个数组段。下标0表示年,小标1表示月,依次类推...
#date1=datetime.datetime(date1[0],date1[1],date1[2],date1[3],date1[4],date1[5])
#date2=datetime.datetime(date2[0],date2[1],date2[2],date2[3],date2[4],date2[5])
date1=datetime.datetime(date1[0],date1[1],date1[2])
date2=datetime.datetime(date2[0],date2[1],date2[2])
#返回两个变量相差的值,就是相差天数
return date2-date1
def isupdata(code):
url='http://fund.eastmoney.com/'+code+'.html'
r=requests.get(url)
r.encoding='utf-8'
soup=BeautifulSoup(r.text,'html.parser')
data=soup.find_all('div',{
'class':'poptableWrap singleStyleHeight01'})
td=data[0].find_all('td')
mon=int((td[0].string.split('-'))[0])
day