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 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()