def parse_medium(self, medium, sensitive): ''' Helper function to parse a medium ''' medium_class_type = medium.get('class', '')[0] medium_type = medium_class_type[3:medium_class_type.index("--")] if (medium_type == "image"): return Medium(image_src=htmlParser.get_image_src( medium, {'class': "mc-image--wrapper"}, html_tag="div"), medium_type=medium_type, sensitive=sensitive) image_src = htmlParser.get_image_src( medium, {'class': f"mc-{medium_type}--image"}, html_tag="div") title = htmlParser.get_text(medium, 'span', {'class': f"mc-{medium_type}--title"}) excerpt = htmlParser.get_text(medium, 'span', {'class': f"mc-{medium_type}--excerpt"}) link_element = htmlParser.get_element_by_css( medium, f'span.mc-{medium_type}--link') link_src = None if link_element is None else htmlParser.get_text( link_element, 'a', {}).strip() return Medium(image_src=image_src, title=title, excerpt=excerpt, link_src=link_src, medium_type=medium_type, sensitive=sensitive)
def get_description(self): ''' Parses the profile page to get the "profile--bio" to get the user profile description as well as any hashtags inside. Returns (str, Hashtags) ''' return htmlParser.get_text(self.profile_page, 'span', {'class': 'profile--bio'})
def get_username(self): username = htmlParser.get_text(self.profile_page, 'span', {'class': 'profile--username'}) if (username is not None and not username.startswith("@")): username = "******" + username return username
def get_view_count(self): return htmlParser.get_text(self.post, 'span', {'class': 'impressions--count'})
def get_timestamp(self): self.timestamp = htmlParser.get_text(self.post, 'span', {'class': 'post--timestamp'}) return self.timestamp
def get_name(self): return htmlParser.get_text(self.echo_by, 'span', {'class': 'reblock'})[10:]
def get_username(self): return htmlParser.get_text(self.post, 'span', {'class': 'author--username'})
def get_name(self): return htmlParser.get_text(self.profile_page, 'span', {'class': 'profile--name'})
def get_upvote_count(self): return htmlParser.get_text(self.post_element, 'span', {'class': 'pa--item--count'}, index=2)
def get_created_at_from_echo_no_reply(self): timestamp = htmlParser.get_element_by_css(self.post_element, 'div.eb--timestamp') return htmlParser.get_text(timestamp, 'span', {})