update-hib.py
changeset 15 053eabfead09
parent 14 f7112a0f9df7
equal deleted inserted replaced
14:f7112a0f9df7 15:053eabfead09
    43               }
    43               }
    44     def __init__(self, dltype, soup):
    44     def __init__(self, dltype, soup):
    45         self.dltype = dltype
    45         self.dltype = dltype
    46         ids = [attr for attr in soup["class"] if attr != "download"]
    46         ids = [attr for attr in soup["class"] if attr != "download"]
    47         button = soup.find(class_="flexbtn")
    47         button = soup.find(class_="flexbtn")
    48         desc = button.span.string
    48         desc = " ".join(button.span.stripped_strings)
    49         ids.extend(desc.split(" "))
    49         ids.extend(desc.split(" "))
    50         self.id = " ".join(ids)
    50         self.id = " ".join(ids)
    51         def cleanup(attr):
    51         def cleanup(attr):
    52             attr = attr.strip()
    52             attr = attr.strip()
    53             if attr not in ("Download","small",""):
    53             if attr not in ("Download","small",""):
   133             if type(child) is not bs4.element.Tag:
   133             if type(child) is not bs4.element.Tag:
   134                 continue
   134                 continue
   135             classes = child["class"] if "class" in child.attrs else []
   135             classes = child["class"] if "class" in child.attrs else []
   136             if "gameinfo" in classes:
   136             if "gameinfo" in classes:
   137                 divTitle = child.find(class_="title")
   137                 divTitle = child.find(class_="title")
   138                 if divTitle.a:
   138                 self.title = " ".join(divTitle.stripped_strings)
   139                     divTitle = divTitle.a
       
   140                 self.title = divTitle.string.strip()
       
   141             elif "downloads" in classes:
   139             elif "downloads" in classes:
   142                 logging.debug("Collecting downloadables for %s", self.title)
   140                 logging.debug("Collecting downloadables for %s", self.title)
   143                 self.downloads.append(Downloads(child))
   141                 self.downloads.append(Downloads(child))
   144             elif [True for attr in classes if attr in ["icn", "clearfix"]]:
   142             elif [True for attr in classes if attr in ["icn", "clearfix"]]:
   145                 pass
   143                 pass