def __get_image_or_video(self, soup): content = Content() item = soup.find('img', {'class': 'post-image'}) if item is not None: src = item.get('src') content.src = src if src.endswith(".gif"): content.type = "gif" else: content.type = "image" return content else: return None
def __get_image_or_video(self, soup): content = Content() link = soup.find("a", {'class': 'title'}) if link is not None: #expand = soup.find("div", {'class': 'expando-button'}) # this means it's a gif or video src = link.get('href') thumbnail_placeholder = soup.find("a", {'class': 'thumbnail'}) thumbnail_src = '' if thumbnail_placeholder is not None: thumbnail_src = thumbnail_placeholder.find("img").get('src') if not src.strip().endswith( ('.jpg', '.jpeg', '.gif', '.png', '.bmp', '.tiff', '.tif', '.jpe', '.jfif')): content.src = src content.type = 'video/mp4' content.thumbnail = thumbnail_src else: content.src = link.get('href') content.type = 'image' content.thumbnail = thumbnail_src return content
def __get_image_or_video(self, ele): content = Content() video = ele.find("source") if video is not None: content.type = 'video/mp4' content.src = video.get('src') thumbnail = ele.find("img", {'class': 'badge-item-img'}) if thumbnail is not None: thumbnail = thumbnail.get('src') content.thumbnail = thumbnail else: content.thumbnail = '' return content else: image = ele.find("img", {'class': 'badge-item-img'}) if image is not None: content.type = 'image' content.src = image.get('src') content.thumbnail = '' return content else: return None
def __get_image_or_video(self, soup): #more like get video content = Content() video = soup.find('video') if video is not None: src = soup.findAll('source')[1] src = src.get("src") content.src = src content.type = 'video/mp4' thumbnail = video.get("poster") content.thumbnail = self.website + thumbnail return content else: return None