def setUpClass(cls): url = 'http://www.zhihu.com/question/24825703' file_path = os.path.join(TEST_DATA_PATH, 'question.html') with open(file_path, 'rb') as f: html = f.read() soup = BeautifulSoup(html) cls.question = Question(url) cls.question._session = None cls.question.soup = soup cls.expected = {'id': 24825703, 'qid': 2112271, 'xsrf': 'cfd489623d34ca03adfdc125368c6426', 'html': soup.prettify(), 'title': '关系亲密的人之间要说「谢谢」吗?', 'details': description, 'answer_num': 621, 'follower_num': 4427, 'top_answer_id': 39753456, 'top_answer_author_name': '芝士就是力量', 'top_answer_upvote_num': 97, 'top_50_ans_id': 31003847, 'top_50_ans_author_name': '圭多达莱佐', 'top_50_ans_upvote_num': 31, 'more_ans_id': 39958704, 'more_ans_author_name': '柳蜻蜓', 'more_ans_upvote_num': 1, 'topics': ['心理学', '恋爱', '社会', '礼仪', '亲密关系'], } more_ans_file_path = os.path.join(TEST_DATA_PATH, 'question_more_answer.html') with open(more_ans_file_path, 'rb') as f: cls.more_ans_html = f.read()
def setUpClass(cls): url = 'http://www.zhihu.com/question/24825703' file_path = os.path.join(TEST_DATA_PATH, 'question.html') with open(file_path, 'rb') as f: html = f.read() soup = BeautifulSoup(html) cls.question = Question(url) cls.question._session = None cls.question.soup = soup cls.expected = { 'id': 24825703, 'qid': 2112271, 'xsrf': 'cfd489623d34ca03adfdc125368c6426', 'html': soup.prettify(), 'title': '关系亲密的人之间要说「谢谢」吗?', 'details': description, 'answer_num': 621, 'follower_num': 4427, 'top_answer_id': 39753456, 'top_answer_author_name': '芝士就是力量', 'top_answer_upvote_num': 97, 'top_50_ans_id': 31003847, 'top_50_ans_author_name': '圭多达莱佐', 'top_50_ans_upvote_num': 31, 'more_ans_id': 39958704, 'more_ans_author_name': '柳蜻蜓', 'more_ans_upvote_num': 1, 'topics': ['心理学', '恋爱', '社会', '礼仪', '亲密关系'], } more_ans_file_path = os.path.join(TEST_DATA_PATH, 'question_more_answer.html') with open(more_ans_file_path, 'rb') as f: cls.more_ans_html = f.read()
def setUpClass(cls): url = 'http://www.zhihu.com/question/24825703/answer/30975949' file_path = os.path.join(TEST_DATA_PATH, 'answer.html') with open(file_path, 'rb') as f: html = f.read() soup = BeautifulSoup(html) answer_saved_path = os.path.join(TEST_DATA_PATH, 'answer.md') with open(answer_saved_path, 'rb') as f: cls.answer_saved = f.read() cls.answer = Answer(url) cls.answer._session = None cls.answer.soup = soup cls.expected = { 'id': 30975949, 'aid': 7775236, 'xsrf': 'cfd489623d34ca03adfdc125368c6426', 'html': soup.prettify(), 'author_id': 'tian-ge-xia', 'author_name': '甜阁下', 'question_id': 24825703, 'question_title': '关系亲密的人之间要说「谢谢」吗?', 'upvote_num': 1164, 'upvoter_name': 'Mikuroneko', 'upvoter_id': 'guo-yi-hui-23' }
def setUpClass(cls): url = 'http://www.zhihu.com/question/24825703/answer/30975949' file_path = os.path.join(TEST_DATA_PATH, 'answer.html') with open(file_path, 'rb') as f: html = f.read() soup = BeautifulSoup(html) answer_saved_path = os.path.join(TEST_DATA_PATH, 'answer.md') with open(answer_saved_path, 'rb') as f: cls.answer_saved = f.read() cls.answer = Answer(url) cls.answer._session = None cls.answer.soup = soup cls.expected = {'id': 30975949, 'aid': 7775236, 'xsrf': 'cfd489623d34ca03adfdc125368c6426', 'html': soup.prettify(), 'author_id': 'tian-ge-xia', 'author_name': '甜阁下', 'question_id': 24825703, 'question_title': '关系亲密的人之间要说「谢谢」吗?', 'upvote_num': 1164, 'upvoter_name': 'Mikuroneko', 'upvoter_id': 'guo-yi-hui-23'}