def _dict_to_news(d): news = News() news.date = d['date'] news.title = d['title'] news.thumbnailUrl = d['thumbnailUrl'] news.questions.extend([_dict_to_question(qd) for qd in d['questions']]) return news
def to_news(self, story): questions = ZhihuDailyOfficial._questions(story) news = News() news.date = self.date news.title = story.metadata.title news.thumbnailUrl = story.metadata.thumbnail_url news.questions.extend([q for q in questions if q]) return news if news.questions else None
def to_news(self, pair): story, document = pair questions = ZhihuDailyOfficial._questions(pair) news = News() news.date = self.date news.title = story.title news.thumbnailUrl = story.thumbnail_url news.questions.extend([q for q in questions if q]) return news if news.questions else None
def to_news(pair, date): story, document = pair elements = _get_question_elements(document) news = News() news.date = date news.title = story.title news.thumbnailUrl = story.thumbnail_url news.questions.extend( filter(lambda q: _is_question_url_valid(q.url), [_to_question(element, story) for element in elements])) return news
def _to_news(pair, date): story, document = pair question_elements = _get_question_elements(document) news = News() news.date = date news.title = story.title news.thumbnailUrl = story.thumbnail_url news.questions.extend( filter(lambda q: _is_question_url_valid(q.url), [ _to_question(question_element) for question_element in question_elements ])) for question in news.questions: question.title = question.title or story.title return news