def save_to_es(self): article = ArticleType() article.title = self["title"] article.url = self["url"] article.front_image_url = self["front_image_url"] if "front_image_path" in self: article.front_image_path = self["front_image_path"] article.type = self["type"] article.size = self["size"] article.update_time = self["update_time"] article.content = remove_tags(self["content"]) article.tag = self["tag"] article.fav_nums = self["fav_nums"] if "download_urls" in self: article.download_urls = self["download_urls"] article.meta.id = self["url_object_id"] article.suggest = gen_suggestions(ArticleType._doc_type.index, ((article.title, 10), (article.tag, 7))) article.save() #redis_cli.incr("lcsoft_count") return
def process_item(self, item, spider): article = ArticleType() article.title = item["title"] article.url = item["url"] article.front_image_path = item.get("front_image_path") article.front_image_url = item["front_image_url"] article.create_date = item["create_date"] article.praise_nums = item["praise_nums"] article.fav_nums = item["fav_nums"] article.comment_nums = item["comment_nums"] article.tag = item["tag"] article.content = remove_tags(item["content"]) article.meta.id = item["url_object_id"] article.suggest = self.get_suggest(ArticleType._doc_type.index, ((article.title, 10), (article.tag, 7))) article.save() return item