-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTransCreateTime.py
More file actions
68 lines (49 loc) · 2.03 KB
/
TransCreateTime.py
File metadata and controls
68 lines (49 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
'''
Created on 2016年7月21日
@author: rhc
'''
import sys,os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
from vbo3.selenium_vbo_mongo import SeleniumVboMongo
from vbo3.mongo import Mongo
class TransCreateTime(SeleniumVboMongo):
PAGE_SIZE=100
def __init__(self):
self.mongo=Mongo()
#获取一页微博数据,只取WeiboID和CreateTime
def getPageWeibo(self,currentPage):
con = self.mongo.db[self.VBO_VBO_CONTENT_TABLE]
start=(currentPage-1)*self.PAGE_SIZE
limit=self.PAGE_SIZE
return [weibo for weibo in con.find({},{"WeiboID":1,"CreateTime":1,"Author.Accounts":1}).limit(limit).skip(start)]
#将微博的CreateTime设置进微博更新表
def setCreateTimeToVboUpdate(self,weibo):
if weibo is None:
return
con=self.mongo.db[self.VBO_VBO_COMMENT_UPDATE_TABLE]
weiboId=weibo['WeiboID']
createTime=weibo['CreateTime']
accounts=weibo['Author']['Accounts']
con.update({"WeiboID":weiboId},{"$set":{"CreateTime":createTime,"Accounts":accounts}})
#将weibo列表里的CreateTime设置进微博更新表
def processWeiboList(self,weiboList):
if weiboList is None or len(weiboList) == 0:
return
for weibo in weiboList:
self.setCreateTimeToVboUpdate(weibo)
#将所有微博CreateTime设置到更新表
def allVboCreateTimeToVboUpdate(self):
currentPage=1
while True:
weiboList=self.getPageWeibo(currentPage)
self.processWeiboList(weiboList)
if weiboList is None or len(weiboList) < self.PAGE_SIZE:
break
print "%s page finish"%currentPage
currentPage+=1
if __name__ == '__main__':
transCreateTime=TransCreateTime()
transCreateTime.allVboCreateTimeToVboUpdate()