Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
royopa committed Feb 28, 2020
1 parent 84944cb commit bad2078
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
import os


def download_file(url, file_name):
print("Downloading {}".format(url)
def download_file(url, file_path):
response = requests.get(url, stream=True)
with open(file_name, "wb") as handle:

if response.status_code != 200:
print('Arquivo não encontrado', url, response.status_code)
return False

with open(file_path, "wb") as handle:
print('Downloading', url)
for data in response.iter_content():
handle.write(data)
handle.write(data)
handle.close()
return True

Expand Down

0 comments on commit bad2078

Please sign in to comment.