import os import requests from bs4 import BeautifulSoup from src.parsers.base_parser import BaseParser class OkParser(BaseParser): BASE_DIR = os.path.abspath(f"downloads/Odnoklassniki") def get_video_link(self): try: resp = requests.get(self.params["link"]) resp.encoding = self.BASE_ENCODING soup = BeautifulSoup(resp.text, 'lxml') required_div = [div for div in soup.find_all('div', {'class': 'invisible'}) if len(div['class']) < 2][0] link = required_div.find('span').find('span').find('a').get("href") self.params["link"] = link return link except Exception as ex: raise def video_download(self): self.get_video_link() super().video_download()