Skip to content

Commit

Permalink
Torna parâmetros do formulário hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
trevineju committed Jan 13, 2025
1 parent f3041a5 commit 62cd4bc
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions data_collection/gazette/spiders/es/es_vitoria.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class EsVitoriaSpider(BaseGazetteSpider):
name = "es_vitoria"
TERRITORY_ID = "3205309"
TERRITORY_ID = "3205309"
allowed_domains = ["diariooficial.vitoria.es.gov.br"]
start_date = date(2014, 7, 21)

Expand All @@ -25,8 +25,9 @@ class EsVitoriaSpider(BaseGazetteSpider):
"RETRY_HTTP_CODES": [500, 502, 503, 504, 522, 524, 408, 429, 406],
}

FORM_PARAM_YEAR = None
FORM_PARAM_MONTH = None
FORM_PARAM_YEAR = "ctl00$conteudo$ucPesquisarDiarioOficial$ddlAno"
FORM_PARAM_MONTH = "ctl00$conteudo$ucPesquisarDiarioOficial$ddlMes"
FORM_PARAM_PAGINATION = "ctl00$conteudo$ucPesquisarDiarioOficial$grdArquivos"

def start_requests(self):
yield Request(
Expand All @@ -35,8 +36,6 @@ def start_requests(self):
)

def make_year_request(self, response):
self.set_form_params(response)

monthly_dates = rruleset()
monthly_dates.rrule(
rrule(MONTHLY, dtstart=self.start_date, until=self.end_date, bymonthday=[1])
Expand All @@ -55,14 +54,6 @@ def make_year_request(self, response):
meta={"cookiejar": (monthly_date.year, monthly_date.month)},
)

def set_form_params(self, response):
year_select = response.xpath("//select[contains(@id, 'ddlAno')]")
self.FORM_PARAM_YEAR = year_select.attrib["name"]

month_select = response.xpath("//select[contains(@id, 'ddlMes')]")
self.FORM_PARAM_MONTH = month_select.attrib["name"]


def make_month_request(self, response):
year, month = response.meta.get("cookiejar")

Expand Down

0 comments on commit 62cd4bc

Please sign in to comment.