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

Spider for Campo Mourão/PR #438

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions data_collection/gazette/spiders/pr_campo_mourao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from dateparser import parse

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


class PrCampoMouraoSpider(BaseGazetteSpider):
TERRITORY_ID = "4104303"
name = "pr_campo_mourao"
start_urls = ["https://campomourao.atende.net/?pg=diariooficial&pagina=1"]

def parse(self, response):
url_base = response.url[0:56]
page = int(response.url[56:])
ogecece marked this conversation as resolved.
Show resolved Hide resolved

list = response.xpath("//div[@class='nova_listagem ']/div[@class='linha']")

if not list:
return

for row in list:
ogecece marked this conversation as resolved.
Show resolved Hide resolved
date = row.xpath("//div[@class='info']/div[@class='data']/text()").get()
date = parse(date, languages=["pt"]).date()

edition_type = row.xpath(
"//div[@class='info']/div[@class='tipo']/text()"
).get()
edition_number = row.xpath(
"//div[@class='info']/div[@class='titulo']/text()"
).get()
edition_number = edition_number.split(" ")[1]

code = row.xpath("//button[@data-acao='download']/@data-codigo").get()
id = row.xpath("//button[@data-acao='download']/@data-id").get()
ogecece marked this conversation as resolved.
Show resolved Hide resolved

is_extra = True if edition_type == "Extraordinária" else False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_extra = True if edition_type == "Extraordinária" else False
is_extra = edition_type == "Extraordinária"


url = f"https://campomourao.atende.net/atende.php?rot=54002&aca=737&processo=download&codigo={code}&hash={id}"

yield Gazette(
ogecece marked this conversation as resolved.
Show resolved Hide resolved
date=date,
edition_number=edition_number,
file_urls=[url],
is_extra_edition=is_extra,
power="executive_legislative",
)

yield response.follow(url_base + str(page + 1))