import pymongo,requests,time
from datetime import timedelta,date
import charts
client = pymongo.MongoClient('localhost',27017)
ganji = client['ganji']
url_list = ganji['url_list']
item_info=ganji['item_info']
def get_all_dates(date1,date2):
the_date = date(int(date1.split('.')[0]),int(date1.split('.')[1]),int(date1.split('.')[2]))
end_date = date(int(date2.split('.')[0]),int(date2.split('.')[1]),int(date2.split('.')[2]))
days=timedelta(days=1)
while the_date <= end_date:
yield the_date.strftime('%Y.%m.%d')
the_date=the_date+days
def get_all_dates(date1,date2):
the_date = date(int(date1.split('.')[0]),int(date1.split('.')[1]),int(date1.split('.')[2]))
end_date = date(int(date2.split('.')[0]),int(date2.split('.')[1]),int(date2.split('.')[2]))
days=timedelta(days=1)
while the_date <= end_date:
yield the_date.strftime('%Y.%m.%d')
the_date=the_date+days
for i in get_data_within('2015.12.30','2016.01.05',['北京二手手机','北京二手笔记本','北京二手台式机/配件']):
print(i)
options={
'chart':{'zoomType':'xy'},
'title':{'text':'发帖统计量'},
'subtitle':{'text':'可视化图表'},
'xAxis':{'categories':[i for i in get_all_dates('2015.12.24','2016.01.05')]},
'yAxis':{'title':{'text':'数量'}}
}
series=[i for i in get_data_within('2015.12.30','2016.01.05',['北京二手手机','北京二手笔记本','北京二手台式机/配件'])]
charts.plot(series,options=options,show='inline')
学习了find的用法,下一步应当将对数据库的操作和序列、字典的操作再加强一下
理解一下对日期的处理和对update的用法