本文整理汇总了Python中Message.Message.itemMsg方法的典型用法代码示例。如果您正苦于以下问题:Python Message.itemMsg方法的具体用法?Python Message.itemMsg怎么用?Python Message.itemMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.itemMsg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JHSGroupItemWorker
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import itemMsg [as 别名]
#.........这里部分代码省略.........
if self._obj == 'groupitem':
self.run_groupitem(_key, _val)
else:
print '# crawlPageMulti unknown obj = %s' % self._obj
def run_groupitem(self, _key, _val):
m_itemQ = JHSGroupItemQM(self._obj, self._crawl_type, 20, _val)
m_itemQ.createthread()
m_itemQ.run()
item_list = m_itemQ.items
print '# crawl Items num: %d' % len(item_list)
# 删除redis数据库过期商品
def delItem(self, _items):
for _item in _items:
keys = [self.worker_type, _item["item_juId"]]
item = self.redisAccess.read_jhsitem(keys)
if item:
end_time = item["end_time"]
now_time = Common.time_s(self.begin_time)
# 删除过期的商品
if now_time > end_time: self.redisAccess.delete_jhsitem(keys)
# 把商品信息存入redis数据库中
def putItemDB(self, _items):
for _item in _items:
# 忽略已经存在的商品ID
keys = [self.worker_type, _item["item_juId"]]
if self.redisAccess.exist_jhsitem(keys): continue
# 将商品基础数据写入redis
item_val = self.message.itemInfo(_item["r_val"])
val = self.message.itemMsg(item_val)
self.redisAccess.write_jhsitem(keys, val)
# 更新商品信息
def updateItem(self, _item):
keys = [self.worker_type, _item["item_juId"]]
item = self.redisAccess.read_jhsitem(keys)
if item:
item_val = self.message.itemParseInfo(_item["r_val"])
c = False
if item["start_time"] != item_val["start_time"]:
item["start_time"] = item_val["start_time"]
c = True
if item["end_time"] != item_val["end_time"]:
item["end_time"] = item_val["end_time"]
c = True
if c:
self.redisAccess.write_jhsitem(keys, item)
# 查找新商品
def selectNewItems(self, _items):
new_items = []
for _item in _items:
keys = [self.worker_type, _item["item_juId"]]
if self.redisAccess.exist_jhsitem(keys):
self.updateItem(_item)
continue
new_items.append(_item["val"])
return new_items
def scanEndItems(self):
val = (Common.time_s(self.crawling_time),)