Skip to content

Commit

Permalink
Correção listagem de preços
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasgusson committed Dec 25, 2021
1 parent 22ffbdb commit 0e00e74
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions afacinemas_scraper/core/precos.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ def _get_dia_semana_preco(self, soup: BeautifulSoup) -> int:

def _get_precos(self, soup: BeautifulSoup) -> List[Dict]:
elementos = soup.find_all("div", {"class": "col-a-12"})
return [self._get_preco(el) for el in elementos[1:5]]
precos = []
for el in elementos[1:5]:
preco = self._get_preco(el)
if preco:
precos.append(preco)
return precos

def _get_preco(self, soup: BeautifulSoup) -> Dict:
descricao = soup.find("div", {"class": "col-a-8"})
valor = soup.find("div", {"class": "col-a-4"})
return {"descricao": descricao.text, "valor": float(valor.text)}

if descricao and valor:
return {"descricao": descricao.text, "valor": float(valor.text)}

def extract(self, id_cinema: int) -> List[Dict]:
try:
Expand Down

0 comments on commit 0e00e74

Please sign in to comment.