def get_sqs_queue(): sqs_info = zhihufav_sqs.get_messages(10) for sqs in sqs_info: sqs_body = sqs.get_body() receipt_handle = sqs.receipt_handle sqs_json = json.loads(sqs_body) api_url = sqs_json.get("api_url") parent_note = sqs_json.get("parent_note") add_note.delay(api_url, parent_note, receipt_handle)
#!/usr/bin/env python #coding=utf-8 from lib.tasks import add_note # @app.task # def add_note(url): # fav_note = Fav(url) # fav_note.get_content() if __name__=="__main__": add_note.delay('https://api.zhihu.com/answers/83464968') # fav = Fav('https://api.zhihu.com/answers/83464968') # fav.get_content()
__tablename__ = 'collection_queue' cq_id = Column(Integer, primary_key=True) answer_id = Column(Integer, default=None) api_url = Column(String(256), default='') web_url = Column(String(256), default='') title = Column(String(256), default='') is_collected = Column(Integer, default=0) add_time = Column(Integer, default=0) collected_time = Column(Integer, default=0) def __str__(self): return "CollectionQueue => { \ cq_id:%d, answer_id:%d, api_url:'%s', web_url:'%s', title:'%s', \ is_collected:%d, add_time:%d, collected_time:%d}" % ( self.cq_id, self.answer_id, self.api_url, self.web_url, self.title, self.is_collected, self.add_time, self.collected_time) __repr__ = __str__ # @app.task # def add_note(url): # fav_note = Fav(url) # fav_note.get_content() if __name__=="__main__": cq_list = session.query(CollectionQueue.api_url).filter(CollectionQueue.is_collected == 0).all() for cq in cq_list: add_note.delay(cq.api_url)