Lib/Recovery/Content.py
def scrap_metadata(self, route, tag="div", attrs={}):
        """
        Get the metadata of a given letter (route).

        Args:
            route (str): letter ID
            tag (str, optional): tag that contains all the data. Default is div
            attrs (dict, optional): attributes that must have the tag. Default is empty

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

        Returns:
            ans (dict): Dictionary with the metadata
        """
        try:
            path = self.url.replace(".html", "/"+route+"/print.html")
            response = requests.get(path)
            body = BeautifulSoup(response.text, "html.parser")
            elements = body.find_all(tag, attrs=attrs)
            heading = elements[1].text.split("\n")
            title = heading[0]
            author = heading[1].split(": ")[1]
            to = heading[2].split(": ")[1]

            dateAndLocation = heading[3].split(": ")[1]
            location = dateAndLocation.split(", ")[0]
            date = dateAndLocation.split(", ")[1:]
            date = ', '.join(date)

            ans = {"TITLE": title, "AUTHOR": author,
                   "ADDRESSEE": to, "DATE": date,
                   "LOCATION": location}
            return ans
        except Exception as exp:
            Err.reraise(exp, "Page: scrap_metadata")

        Get the metadata of a given letter (route).

        Args:
            route (str): letter ID
            tag (str, optional): tag that contains all the data. Default is div
            attrs (dict, optional): attributes that must have the tag. Default is empty

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

        Returns:
            ans (dict): Dictionary with the metadata
        
Get the metadata of a given letter (route).
Get the metadata of a given letter ( route ) .
def scrap_metadata(self, route, tag="div", attrs={}):
        try:
            path = self.url.replace(".html", "/"+route+"/print.html")
            response = requests.get(path)
            body = BeautifulSoup(response.text, "html.parser")
            elements = body.find_all(tag, attrs=attrs)
            heading = elements[1].text.split("\n")
            title = heading[0]
            author = heading[1].split(": ")[1]
            to = heading[2].split(": ")[1]
            dateAndLocation = heading[3].split(": ")[1]
            location = dateAndLocation.split(", ")[0]
            date = dateAndLocation.split(", ")[1:]
            date = ', '.join(date)
            ans = {"TITLE": title, "AUTHOR": author,
                   "ADDRESSEE": to, "DATE": date,
                   "LOCATION": location}
            return ans
        except Exception as exp:
            Err.reraise(exp, "Page: scrap_metadata")
def scrap_metadata ( self , route , tag = "div" , attrs = { } ) : try : path = self . url . replace ( ".html" , "/" + route + "/print.html" ) response = requests . get ( path ) body = BeautifulSoup ( response . text , "html.parser" ) elements = body . find_all ( tag , attrs = attrs ) heading = elements [ 1 ] . text . split ( "\n" ) title = heading [ 0 ] author = heading [ 1 ] . split ( ": " ) [ 1 ] to = heading [ 2 ] . split ( ": " ) [ 1 ] dateAndLocation = heading [ 3 ] . split ( ": " ) [ 1 ] location = dateAndLocation . split ( ", " ) [ 0 ] date = dateAndLocation . split ( ", " ) [ 1 : ] date = ', ' . join ( date ) ans = { "TITLE" : title , "AUTHOR" : author , "ADDRESSEE" : to , "DATE" : date , "LOCATION" : location } return ans except Exception as exp : Err . reraise ( exp , "Page: scrap_metadata" )
Get the metadata of a given letter (route).
Get the metadata of a given letter ( route ) .
"""
        Get the metadata of a given letter (route).

        Args:
            route (str): letter ID
            tag (str, optional): tag that contains all the data. Default is div
            attrs (dict, optional): attributes that must have the tag. Default is empty

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

        Returns:
            ans (dict): Dictionary with the metadata
        """
ans (dict): Dictionary with the metadata
ans ( dict ) : Dictionary with the metadata
raise a generic exception if something goes wrong
raise a generic exception if something goes wrong
exp
self
route
None
tag
tag that contains all the data. Default is div
tag that contains all the data . Default is div
attrs
attributes that must have the tag. Default is empty
attributes that must have the tag . Default is empty