Skip to content

Commit

Permalink
Merge pull request #12 from jacksonsr451/v1.0.2-beta
Browse files Browse the repository at this point in the history
Refactoring: add sanitise strings in states name by generation files
  • Loading branch information
jacksonsr451 authored Jan 26, 2022
2 parents 05f5653 + b310520 commit 774fea1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,16 @@
driver.back()
driver.get(url=url_states_and_cities)

name_file_state = "".join((re.sub("á", "a", save_td_data["estado"].lower())))
name_file_state = "".join((re.sub(" ", "_", name_file_state)))
name_file_state = "".join((re.sub("ã", "a", name_file_state)))
name_file_state = "".join((re.sub("í", "i", name_file_state)))
name_file_state = "".join((re.sub("ô", "o", name_file_state)))

name_state = save_td_data['estado'].lstrip()
# Ciando arquivos .json
with open(f'states_files_json/cities_by{"".join(re.sub(r" ", "_", save_td_data["estado"].lower()))}.json', 'w', encoding="utf-8") as f:
json.dump({"estado": save_td_data["estado"], "posição": save_td_data["posicao"],
with open(f'states_files_json/cities_by{name_file_state}.json', 'w', encoding="utf-8") as f:
json.dump({"estado": name_state, "posição": save_td_data["posicao"],
"sigla": save_td_data["sigla"], "municipios": save_td_data['municipios']}, f, ensure_ascii=False, indent=4)

table_of_states_and_cities = driver.find_element(By.XPATH, '//*[@id="mw-content-text"]/div[1]/table[3]/tbody')
Expand Down

0 comments on commit 774fea1

Please sign in to comment.