def get_staff_forum_posts(thread_id, search_start=1): """ returns: a list of StaffPosts for each post made by a staff member in the page the new page count value that has been searched to search_start is the page number to begin the search from """ posts = [] # forum has feature to only get staff posts from the thread page_count = get_page_count(filter_staff(url_of_id(thread_id))) for i in range(search_start, page_count + 1): soup = get_page_soup( filter_staff(url_of_id(thread_id)) + "/page/" + str(i)) # get the table of forum rows post_table = soup.find("table", class_="forumPostListTable") if post_table is None: # catch all for cases where the page returns something that isn't a forum post list # for whatever reason return [], 0 for row in post_table.find_all("tr"): # ignore if this isn't a staff post at all (I've seen this for poll threads) if not row.has_attr("class"): continue # if this row is one of the newspost details rows, ignore it if "newsPostInfo" in row["class"]: continue author = get_post_author_from_row(row) post_id = get_post_id_from_row(row) # convert the retrieved html into markdown text = htmltomd.quote_boxify( htmltomd.convert(str(get_post_from_row(row)))) post_date = get_post_date_from_row(row) # a bug in the website sometimes causes 2 pages of forum posts to return the same forum post if not check_for_duplicate(posts, post_id): posts.append( StaffPost(post_id, thread_id, author, text, post_date)) return posts, page_count
def test_pre_complex(self): html, expected_output = self.load_values_v2('pre_complex') self.assertEqual(expected_output, htmltomd.convert(html))
def test_inline_code(self): html, expected_output = self.load_values_v2('inline_code') self.assertEqual(expected_output, htmltomd.convert(html))
def test_basic(self): html, expected_output = self.load_values('basic') self.assertEqual(expected_output, htmltomd.convert(html))
def test_iframe_embed(self): html, expected_output = self.load_values('iframe_embed') self.assertEqual(expected_output, htmltomd.convert(html))
def test_nested_quote(self): html, expected_output = self.load_values('nested_quote') self.assertEqual(expected_output, (htmltomd.convert(html)))
def test_nested_types(self): html, expected_output = self.load_values('nested_types') self.assertEqual(expected_output, htmltomd.convert(html))
def test_raw_embedded_video(self): html, expected_output = self.load_values('raw_embedded_video') self.assertEqual(expected_output, htmltomd.convert(html))
def test_italics_whitespace(self): html, expected_output = self.load_values('italics_whitespace') self.assertEqual(expected_output, htmltomd.convert(html))
def test_a(self): html, expected_output = self.load_values('a') self.assertEqual(expected_output, htmltomd.convert(html)) html, expected_output = self.load_values('a_no_href') self.assertEqual(expected_output, htmltomd.convert(html))
def test_list(self): html, expected_output = self.load_values('list') self.assertEqual(expected_output, htmltomd.convert(html))
def test_successive_tags(self): html, expected_output = self.load_values('successive') self.assertEqual(expected_output, htmltomd.convert(html))
def test_empty_tag(self): html, expected_output = self.load_values('empty_tag') self.assertEqual(expected_output, htmltomd.convert(html))
def test_table_tag(self): html, expected_output = self.load_values_v2('table') self.assertEqual(expected_output, htmltomd.convert(html))
def test_quote_challenge_titles(self): html, expected_output = self.load_values_v2('challenge_quote') self.assertEqual(expected_output, htmltomd.convert(html))
def test_strong_inline(self): html, expected_output = self.load_values('strong_inline') self.assertEqual(expected_output, htmltomd.convert(html))
def test_code_quoteboxed(self): html, expected_output = self.load_values_v2('code_quoteboxed') self.assertEqual(expected_output, htmltomd.convert(html))