예제 #1
0
 def open(self):
     try:
         self.fd = open(self.tfile, "a+")
         for line in self.fd.readlines():
             t = Tweet()
             t.parse(line)
             self.tmap[t.mid] = t
     except Exception, ex:
         print str(ex)
예제 #2
0
 def getTweet_(self,mid):
     logger.info("crawling tweet %s"%(mid))
     status = self.weiboCrawler.statuses.show.get(id=mid)
     t = Tweet()
     if status:
         rt=None
         for k,v in status.items():
             if k == "user":
                 t.setattr('uid', v['id'])
             elif k == "retweeted_status":
                 t.setattr("rtmid", v['mid'])
                 rtuser = v['user']
                 if rtuser:
                     rt = "@%s:%s"%(v["text"], rtuser['name'])
             else:
                 t.setattr(k,v)
         if rt:
             t.setattr("text", "%s//%s"%(t.text, rt))
         return t
     else:
         return None
예제 #3
0
 def getTweet(self, mid):
     redis = self.redisCluster.getRedis(mid, TWEET_DB)
     t = Tweet()
     for field in t.schema:
         t.setattr(field, redis.hget(mid, field))
예제 #4
0
 def open(self):
     self.fd = open(self.tfile)
     for line in self.fd.readlines():
         t = Tweet()
         t.parse(line)
         self.tmap[t.mid] = t