Skip to content
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

Criado Spider para MG Piumhi #1044

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
36 changes: 36 additions & 0 deletions data_collection/gazette/spiders/mg/mg_piumhi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from datetime import date

from gazette.items import Gazette
from gazette.spiders.base import BaseGazetteSpider


class MgPiumhiSpider(BaseGazetteSpider):
name = "mg_piumhi"
TERRITORY_ID = "3151503"
allowed_domains = ["prefeiturapiumhi.mg.gov.br"]
start_date = date(2023, 9, 11)
start_urls = ["https://diario-oficial.prefeiturapiumhi.mg.gov.br/"]

def parse(self, response):
gazettes = response.css(
"div.jet-listing-grid__items div.jet-listing-grid__item"
)
for gazette in gazettes:
gazette.css("div.jet-listing-dynamic-field__content::text").re_first(
r"(\d{2}/\d{2}/\d{4})"
)

if date > self.end_date:
continue
elif date < self.start_date:
continue

file_urls = gazette.css("a::attr(href)").getall()
edition_number = gazette.css("h2::text").re_first(r"\d+")
yield Gazette(
date=date,
edition_number=edition_number,
file_urls=file_urls,
power="executive",
is_extra_edition=False,
)
Loading