Lib/Recovery/Content.py
def scrap_artworks(self, route):
        """
        Scrap all the artowrks of a given letter.

        Args:
            route (str): letter id to scrap artworks.

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): dict with all the data of the artworks of the given letter
        """
        try:
            links = []
            titles = []
            Fs = []
            JHs = []
            ids = []

            path = self.url.replace(".html", "/"+route+"/letter.html")

            driver = webdriver.Firefox()
            driver.maximize_window()
            driver.get(path)
            driver.refresh()
            driver.find_element_by_link_text("works of art").click()
            x = driver.find_elements_by_class_name("image")
            for i in x:
                a = i.find_element_by_tag_name("a")
                img = a.find_element_by_tag_name("img")
                image_link = img.get_attribute("src").replace("t.jpg", ".jpg")
                title = img.get_attribute('title')
                F = re.findall(r'F\s\d+', title)
                JH = re.findall(r'JH\s\d+', title)
                if len(F) > 0:
                    F = F[0]
                else:
                    F = ""
                if len(JH) > 0:
                    JH = JH[0]
                else:
                    JH = ""

                # parsing the URL to choose the local folder to save the file
                imgf = image_link.split("/")[-1].replace(".jpg", "")
                ids.append(imgf)
                links.append(image_link)
                Fs.append(F)
                JHs.append(JH)
                titles.append(title)

            driver.close()
            ans = {"ARTWORKSTITLE": titles, "ARTWORKSF": Fs,
                   "ARTWORKSJH": JHs, "ARTWORKSLINK": links, "ARTWORKSID": ids}
            return ans

        except Exception as exp:
            Err.reraise(exp, "Page: scrap_artworks")

        Scrap all the artowrks of a given letter.

        Args:
            route (str): letter id to scrap artworks.

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): dict with all the data of the artworks of the given letter
        
Scrap all the artowrks of a given letter.
Scrap all the artowrks of a given letter .
def scrap_artworks(self, route):
        try:
            links = []
            titles = []
            Fs = []
            JHs = []
            ids = []
            path = self.url.replace(".html", "/"+route+"/letter.html")
            driver = webdriver.Firefox()
            driver.maximize_window()
            driver.get(path)
            driver.refresh()
            driver.find_element_by_link_text("works of art").click()
            x = driver.find_elements_by_class_name("image")
            for i in x:
                a = i.find_element_by_tag_name("a")
                img = a.find_element_by_tag_name("img")
                image_link = img.get_attribute("src").replace("t.jpg", ".jpg")
                title = img.get_attribute('title')
                F = re.findall(r'F\s\d+', title)
                JH = re.findall(r'JH\s\d+', title)
                if len(F) > 0:
                    F = F[0]
                else:
                    F = ""
                if len(JH) > 0:
                    JH = JH[0]
                else:
                    JH = ""
                imgf = image_link.split("/")[-1].replace(".jpg", "")
                ids.append(imgf)
                links.append(image_link)
                Fs.append(F)
                JHs.append(JH)
                titles.append(title)
            driver.close()
            ans = {"ARTWORKSTITLE": titles, "ARTWORKSF": Fs,
                   "ARTWORKSJH": JHs, "ARTWORKSLINK": links, "ARTWORKSID": ids}
            return ans
        except Exception as exp:
            Err.reraise(exp, "Page: scrap_artworks")
def scrap_artworks ( self , route ) : try : links = [ ] titles = [ ] Fs = [ ] JHs = [ ] ids = [ ] path = self . url . replace ( ".html" , "/" + route + "/letter.html" ) driver = webdriver . Firefox ( ) driver . maximize_window ( ) driver . get ( path ) driver . refresh ( ) driver . find_element_by_link_text ( "works of art" ) . click ( ) x = driver . find_elements_by_class_name ( "image" ) for i in x : a = i . find_element_by_tag_name ( "a" ) img = a . find_element_by_tag_name ( "img" ) image_link = img . get_attribute ( "src" ) . replace ( "t.jpg" , ".jpg" ) title = img . get_attribute ( 'title' ) F = re . findall ( r'F\s\d+' , title ) JH = re . findall ( r'JH\s\d+' , title ) if len ( F ) > 0 : F = F [ 0 ] else : F = "" if len ( JH ) > 0 : JH = JH [ 0 ] else : JH = "" imgf = image_link . split ( "/" ) [ - 1 ] . replace ( ".jpg" , "" ) ids . append ( imgf ) links . append ( image_link ) Fs . append ( F ) JHs . append ( JH ) titles . append ( title ) driver . close ( ) ans = { "ARTWORKSTITLE" : titles , "ARTWORKSF" : Fs , "ARTWORKSJH" : JHs , "ARTWORKSLINK" : links , "ARTWORKSID" : ids } return ans except Exception as exp : Err . reraise ( exp , "Page: scrap_artworks" )
Scrap all the artowrks of a given letter.
Scrap all the artowrks of a given letter .
"""
        Scrap all the artowrks of a given letter.

        Args:
            route (str): letter id to scrap artworks.

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): dict with all the data of the artworks of the given letter
        """ # parsing the URL to choose the local folder to save the file
ans (dict): dict with all the data of the artworks of the given letter
ans ( dict ) : dict with all the data of the artworks of the given letter
raise a generic exception if something goes wrong
raise a generic exception if something goes wrong
exp
self
route
letter id to scrap artworks.
letter id to scrap artworks .