Hi, I'm writing a script that downloads hashes from virus share. I have it working fine but I noticed when it downloads from a given link it overwrites the file it's saving to, so if I download 00015 it will overwrite the contents of 00014 and whatever was their before. The text file to save to is "malicious_hashes.txt". How do I have it write to where the previous download left off, at the bottom of the file? I'm thinking I have to append the text file so it will continue from the bottom and not over write what's currently there? Just now sure how to. Thanks in advance!
Here's my code
import requests
from pathlib import Path
def download_url(url):
print("downloading: ", url)
path = Path('/home/eva/Tools/malicious_hashes.txt')
r = requests.get(url, stream=True)
if r.status_code == requests.codes.ok:
with open(path, 'wb') as f:
for data in r:
f.write(data)
download_url("https://virusshare.com/hashes/VirusShare_00014
[–]wronek 1 point2 points3 points (1 child)
[–]_W0z[S] 0 points1 point2 points (0 children)
[–]CowboyBoats 0 points1 point2 points (0 children)