Python code for TSE data access

Job ID: 33672683

Budget: $10 – $20 USD

WARNING
if you have any proposal that does not comply with the constraints and rules the follow, please, don’t waste your time: it will not be be accepted. So, before jumping swiftly to bid, read the specs.

CONSTRAINTS

a) The solution must be developed in Python. No alternative accepable or even considered;
b) To grab data, solution must use modules like requests, beautifulsoap and selenium or others publicly available;
c) Data wrangling, if needed, should be done with pandas or any other publicly available module;
d) Code must run under linux (Debian 11) without the need of installing any particular package (except Python interpreter itself and the modules referred to above.

Task description – input

1) Data shell come from the url https://sig.tse.jus.br/ords/dwtse/f?p=2001:101:::NO:::
2) Select following fields that should be taken from a list. For the development and testing, only one item will be used (except for the field specified in d):
a) Ano [2022] (Full list: range (1990, current year, step 2)
b) Mes [‘Abril’] (Full list: [‘Janeiro’, ‘Fevereiro’, ‘Marco’, ‘Abril’, ‘Maio’, ‘Junho’, ‘Julho’, ‘Agosto’, ‘Setembro’, ‘Outubro’, ‘Novembero’, ‘Dezembro’])
c) Abrangência [‘Município’] (Full list: [‘Brasil’. ‘Região’, ‘UF’, ‘Município’])
When ‘Brasil’ is selected, no additional information is required. Nevertheless, is the choice is any other, additional information is needed. This can be checked in the url itself (https://sig.tse.jus.br/ords/dwtse/f?p=2001:101:::NO:::)
d) Município [‘Bom Despacho’, ‘Uberaba’, ‘Uberlândia’, ‘Divinópolis’]
e) UF [’MG’] (enough for testing only: [‘MG’, ‘BA’, ‘RJ’])

3) Parameters from a) to e) should be gotten from a function with the following signature and behaviour:
def year():
for y in range (1990, current year, 2):
yield str(y)
muni = [‘Belo Horizonte’, ‘Bom Despacho’, ‘Uberaba’]
def municipality():
for m in muni:
yield m

NOTE: for testing purposes, each these functions do not need to yield for than 2 items, the default, and one more. Exception: the municipality() function should yield three items as listed above)

OUTPUT
Output is a CVS file with the data presented in the table seen as the search result. Same lables, same data, same number of columns and lines. Field separator should be “#”. No quotes needed.
Related categories: Python Data Scraping BeautifulSoup Selenium