from util.repo import REPO class OLDGAMESDOWNLOAD(REPO): def __init__(self): super.__init__(self, "oldgamesdownload") self.baseURL = "https://oldgamesdownload.com" if not self.platforms: self.platforms={ 'Apple':{ 'II': '/browse/platform/apple-ii', 'Macintosh': '/browse/platform/mac' }, 'Atari':{ 'ST': '/browse/platform/atari-st', '800': '/browse/platform/atari-8-bit', '2600': '/browse/platform/atari-2600', '5200': '/browse/platform/atari-5200', '7800': '/browse/platform/atari-7800' }, 'Commodore':{ 'Amiga': '/browse/platform/amiga', '64': '/browse/platform/commodore-64', 'Plus/4': '/browse/platform/commodore-plus-4' }, 'Microsoft':{ 'DOS': '/browse/platform/dos', 'Win32': '/browse/platform/windows', 'Win16': '/browse/platform/windows-3-x' }, 'Sega':{ 'Genesis': '/browse/platform/sega-genesis', 'Master System': '/browse/platform/sega-master-system', 'Saturn': '/browse/platform/sega-saturn', 'Dreamcast': '/browse/platform/dreamcast' }, 'Sony':{ 'Playstation': '/browse/platform/playstation', 'Playstation 2': '/browse/platform/playstation-2' }, 'Other':{ 'Arcade': '/browse/platform/arcade', 'ColecoVision': '/browse/platform/colecovision' } } def get(self, path): super().get(f'{self.baseURL}{path}') return self.data def getArticle(self, soup): '''get the articles from a page and return them as a list of dictionaries containing each Game, URL, Img''' # list to return article = [] # find all
tabs in the
articles = soup.find(id='main').find_all('article') for this in articles: # the first
in the article that has the background image, name, and link div = this.find_all('div')[0] # the first tag in the div that has the link and name link = div.find_all('a')[0] article.append({ # add the Game name from the text of the link 'Game': link.text(), # add the URL for the game page from the link href 'URL': link['href'], # add the Img for the game from the div background 'Img': div['style'].split('(')[1][:-2] }) return article def update(self): newgames = self.getArtcle(self.get()) super().update(newgames)