def update_gem_icon(self, soup): """Scrapes web soup for gem_icon, saves in img/ and returns filename""" if self.name == '': return None gem_icon = soup.find(class_="infobox-page-container").find('img') self.gem_icon = gem_icon['alt'].replace(' ', '') local_file_path = 'img/' + self.gem_icon save_url(gem_icon['src'], local_file_path) return self.gem_icon
def update_skill_icon(self, soup): """ Scrapes skill_icon from soup Saves in img/ self.skill_icon = filename Returns filename """ soup = soup.find(class_="itembox-gem Active Skill Gems") try: icon = soup.find_all("img")[1] except AttributeError: return False local_file_name = icon['alt'].replace(' ', '') local_file_path = 'img/' + local_file_name save_url(icon['src'], local_file_path) self.skill_icon = local_file_name return self.skill_icon
def save_html(self, name=''): """Uses 'name' or 'self.name' to fetch wiki page and save in data/ Returns location of file""" if name == '' and self.name == '': return False if name != '': self.name = name name = self.name.replace(' ', '_') url = Gem.HOST + name location = 'data/%s.html' % (name) try: result = save_url(url, location) return result except HTTPError: return False