Skip to content

Commit

Permalink
Adicionar verificação de ip
Browse files Browse the repository at this point in the history
  • Loading branch information
Winzen committed Nov 27, 2024
1 parent f4d7292 commit efe9573
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pipelines/utils/crawler_tse_eleicoes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,16 @@ def download_extract_zip(self, url: str, chunk_size=128) -> None:
"https": self.proxy
}

proxy_test = requests.get('https://api.myip.com/', proxies=proxies, verify=False)
log(proxy_test)

r = requests.get(url, headers=request_headers, proxies=proxies, verify=False, timeout=300)
r = requests.get(url, headers=request_headers, proxies=proxies, stream=True, verify=False, timeout=300)

save_path = self.path_input / url.split("/")[-1]

with open(save_path, "wb") as fd:
fd.write(r.content)

# with open(save_path, "wb") as fd:
# for chunk in r.iter_content(chunk_size=chunk_size):
# fd.write(chunk)
# fd.write(r.content)

with open(save_path, "wb") as fd:
for chunk in r.iter_content(chunk_size=chunk_size):
fd.write(chunk)

with zipfile.ZipFile(save_path) as z:
z.extractall(self.path_input)
Expand Down

0 comments on commit efe9573

Please sign in to comment.