-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Curitiba #42
Curitiba #42
Changes from 1 commit
6d96ebe
eb5fad9
f5f7b9d
e1aba53
82ae630
a7cee8d
4ff9256
56aff21
4f29761
ebc0b73
8c5c3c9
c6c18f6
587dfa2
3165684
e30ae42
838aeee
4e3ab65
fd0b0bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from dateparser import parse | ||
import datetime as dt | ||
import re | ||
|
||
import scrapy | ||
|
||
|
||
from gazette.items import Gazette | ||
|
||
class PrCuritibaSpider(scrapy.Spider): | ||
|
@@ -73,10 +75,21 @@ def parse_page(self, response): | |
id = ids[i] | ||
parsed_date = parse(f'{pdf_date}', languages=['pt']).date() | ||
if id == '0': | ||
print("Nao suplemento") | ||
print("Number is {0} date is {1} is is {2}".format(number, parsed_date, id)) | ||
self.scrap_not_extra_edition(response, i) | ||
gazettes.append(self.scrap_not_extra_edition(response, i)) | ||
yield scrapy.FormRequest.from_response(response, | ||
headers = { | ||
'user-agent': 'Mozilla/5.0', | ||
}, | ||
formdata = { | ||
'__LASTFOCUS': '', | ||
'__EVENTTARGET': 'ctl00$cphMasterPrincipal$gdvGrid2$ctl{num:02d}$lnkVisualizar'.format(num=(i+3)), | ||
'__EVENTARGUMENT': '', | ||
'__ASYNCPOST': 'true' | ||
}, | ||
callback=self.scrap_not_extra_edition, | ||
meta={"gazettes": gazettes, "parsed_date": parsed_date} | ||
) | ||
|
||
#gazettes.append(yield self.scrap_not_extra_edition(response, i)) | ||
else: | ||
gazettes.append(Gazette( | ||
date = parsed_date, | ||
|
@@ -86,25 +99,18 @@ def parse_page(self, response): | |
power='executive_legislature', | ||
scraped_at=dt.datetime.utcnow() | ||
)) | ||
|
||
|
||
return []#gazettes | ||
|
||
def scrap_not_extra_edition(self, response, index): | ||
#window.open('DiarioConsultaExterna_Download.aspx?Id=2508' | ||
print('ctl00$cphMasterPrincipal$gdvGrid2$ctl{num:02d}$lnkVisualizar'.format(num=(index+3))) | ||
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ==== {num:02d}".format(num=(index+3))) | ||
yield scrapy.FormRequest.from_response( | ||
response, | ||
formdata={ | ||
'__EVENTTARGET' : 'ctl00$cphMasterPrincipal$gdvGrid2$ctl{num:02d}$lnkVisualizar'.format(num=(index+3)), | ||
'ctl00$smrAjax' : 'ctl00$cphMasterPrincipal$upPesquisaExternaDO|ctl{num:02d}$cphMasterPrincipal$gdvGrid2$ctl05$lnkVisualizar'.format(num=(index+3)), | ||
'__ASYNCPOST': 'true', | ||
'__VIEWSTATEGENERATOR': 'B3FCDD96' | ||
}, | ||
callback=self.parse_gazette_popup, | ||
) | ||
|
||
def parse_gazette_popup(self, response): | ||
print("SDFFFFFFFFFFFFFFAFDEHJAERDJREJAJHGEARJ") | ||
print(response.text) | ||
def scrap_not_extra_edition(self, response): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
gazettes = response.meta['gazettes'] | ||
parsed_date = response.meta['parsed_date'] | ||
id = re.findall(r'Id=(\d+)', response.text ) | ||
gazettes.append(Gazette( | ||
date = parsed_date, | ||
file_urls=["http://legisladocexterno.curitiba.pr.gov.br/DiarioConsultaExterna_Download.aspx?id={}".format(id)], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
is_extra_edition= False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
municipality_id=self.MUNICIPALITY_ID, | ||
power='executive_legislature', | ||
scraped_at=dt.datetime.utcnow() | ||
)) |
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.
Inherit from
BaseGazetteSpider
(https://github.com/okfn-brasil/diario-oficial/blob/master/processing/data_collection/gazette/spiders/base.py#L6) to allow date filtering by item pipelines.