def display_results(url, dup_link=None, json_output=False): """ Display result page :param url: URL of the search result :param dup_link: URL to the duplicate question visited from :param json_output: JSON output flag :return: """ search.random_headers() res_page = requests.get(url, headers=search.header) search.captcha_check(res_page.url) question_title, question_desc, question_stats, answers, comments, dup_url = \ search.get_question_stats_and_answer_and_comments(url) if json_output: sys.stdout.write( urllib.parse.unquote( json.dumps({ 'title': question_title, 'desc': question_desc, 'stats': question_stats, 'answers': answers, 'comments': comments, 'dup_url': dup_url, }))) else: tui.display_header = tui.Header() tui.question_post = tui.QuestionPage( (url, question_title, question_desc, question_stats, answers, comments, dup_url, dup_link)) tui.MAIN_LOOP = tui.EditedMainLoop(tui.question_post, palette) tui.MAIN_LOOP.run()
def select_question(self, url, index): if self.cachedQuestions[index] is not None: tui.question_post = self.cachedQuestions[index] tui.MAIN_LOOP.widget = tui.question_post else: if not search.google_search: url = search.so_url + url question_title, question_desc, question_stats, answers = search.get_question_stats_and_answer(url) question_post = tui.QuestionPage((answers, question_title, question_desc, question_stats, url)) self.cachedQuestions[index] = question_post tui.MAIN_LOOP.widget = question_post
def select_question(self, url, index): if self.cachedQuestions[index] is not None: tui.question_post = self.cachedQuestions[index] tui.MAIN_LOOP.widget = tui.question_post else: if not search.search_engine == 'google': url = search.so_url + url question_title, question_desc, question_stats, answers, comments, dup_url = \ search.get_question_stats_and_answer_and_comments(url) question_post = tui.QuestionPage( (url, question_title, question_desc, question_stats, answers, comments, dup_url)) self.cachedQuestions[index] = question_post tui.MAIN_LOOP.widget = question_post
def display_results(url): """ Display result page :param url: URL of the search result :return: """ search.random_headers() res_page = requests.get(url, headers=search.header) search.captcha_check(res_page.url) tui.display_header = tui.Header() question_title, question_desc, question_stats, answers = search.get_question_stats_and_answer(url) tui.question_post = tui.QuestionPage((answers, question_title, question_desc, question_stats, url)) tui.MAIN_LOOP = tui.EditedMainLoop(tui.question_post, palette) tui.MAIN_LOOP.run()