-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ma_timon #1012
base: main
Are you sure you want to change the base?
ma_timon #1012
Conversation
ocorreu apenas um erro referente ao arquivo suplementar do dia 12/05/2021, no qual realmente não existe |
from gazette.spiders.base import BaseGazetteSpider | ||
|
||
|
||
class AmManausSpider(BaseGazetteSpider): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problema O nome do spider está incorreto.
class AmManausSpider(BaseGazetteSpider): | ||
name = "ma_timon" | ||
start_date = datetime.date(2013, 3, 20) | ||
start_urls = ["https://timon.ma.gov.br/diario/pesquisa.php"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestão Quando usamos o start_requests
para realizar os primeiros requests do spider, não usamos o start_urls
(que na prática é apenas uma abstração para o start_requests
)
|
||
TERRITORY_ID = "2112209" | ||
|
||
def start_requests(self) -> scrapy.FormRequest: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestão No projeto não estamos utilizando tipagem de nenhum tipo. Para manter o projeto consistente, não adicionar tipos.
base_url = "https://timon.ma.gov.br/diario/pesquisa.php" | ||
|
||
params = { | ||
"TipoDiario_datas": "Executivo", # (Legislativo, Executivo, Todos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestão: COmentário desnecessário, já que só obtemos diários do executivo nesse spider.
method="POST", | ||
formdata=params, | ||
callback=self.parse, | ||
# cb_kwargs={"params": params}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problema Não deixe código comentado. Isso apenas aumenta o ruído dentro do código dificultando a leitura.
|
||
def parse(self, response) -> Gazette: | ||
trs = response.xpath( | ||
"/html/body/div/header/div[2]/header/div/div[1]/header/div[2]/div/div/table/tbody/tr" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problema Esse XPath está extremamente específico. O ideal é ser mais geral e mais simples, de modo a não quebrar simplesmente se um div
aparecer sem quebrar todo o resto do layout.
) | ||
|
||
def parse(self, response) -> Gazette: | ||
trs = response.xpath( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestão trs
não é um bom nome para essa variável, já que não temos nenhuma ideia do que isso significa. gazettes
é um nome melhor.
trs = response.xpath( | ||
"/html/body/div/header/div[2]/header/div/div[1]/header/div[2]/div/div/table/tbody/tr" | ||
) | ||
for tr in trs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestão Com nomes melhores: for gazette in gazettes:
"/html/body/div/header/div[2]/header/div/div[1]/header/div[2]/div/div/table/tbody/tr" | ||
) | ||
for tr in trs: | ||
# import pdb; pdb.set_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problema Não deixe código comentado. Só aumenta a desorganização do código.
AO ABRIR um Pull Request de um novo raspador (spider), marque com um
X
cada um dos items do checklistabaixo. NÃO ABRA um novo Pull Request antes de completar todos os items abaixo.
Checklist - Novo spider
start_date
eend_date
definidos) ao menos uma vez e os dados retornados estavam corretos.log_count/ERROR
igual a zero).start_date
no seu spider com a data do Diário Oficial mais antigo disponível na página da cidade.Descrição
<Descreva o seu Pull Request informando a issue (caso exista) que está sendo solucionada ou uma descrição do código apresentado>