Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to download today's data #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions wget_malshare_daily
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# 02/21/2014 Modified by Jun Xie <[email protected]>
# to download a single day: wget_malshare_daily -d 2014-01-27
# to download a today data to "./data/{date}": wget_malshare_daily
# to download samples within a range: wget_malshare_daily -s 2014-01-27 -e 2014-02-07
#
# Sciprt will create the folder named by date automatically under current directory
Expand All @@ -16,6 +17,7 @@ import os
import re
import sys
import string
import datetime as datetimemod
from datetime import datetime, date, timedelta

api_key =""
Expand Down Expand Up @@ -49,8 +51,7 @@ def main():
print("end_date(%s) is earlier than start_date(%s)" % (str(end_date), str(start_date)))
sys.exit(1)
temp_date = start_date
if not args.outfolder:
args.outfolder="./"

while temp_date <= end_date:
temp_date_str = str(temp_date)
temp_date += timedelta(days=1)
Expand All @@ -76,6 +77,9 @@ def main():
print "sub_path", sub_path
#sys.exit(0)

if not args.outfolder:
args.outfolder = "./data/" + (datetimemod.datetime.utcnow() + datetimemod.timedelta(days=-1)).strftime('%Y-%m-%d')

#download samples of this date
download_daily(args.vxcage, args.outfolder, sub_path)

Expand All @@ -93,6 +97,9 @@ def download_daily(vxcage, outfolder, sub_path):
if (md5_hash):
logging.info("Downloading %s" % md5_hash)
print md5_hash
if md5_hash in os.listdir(outfolder):
print ("Downloaded %s" % md5_hash)
continue
pull_file(md5_hash, vxcage, outfolder)

def pull_daily_list(sub_path):
Expand Down