Skip to content

Instantly share code, notes, and snippets.

@technetbytes
Created June 14, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technetbytes/0842aa7dc70aab6830aca0690e5702b2 to your computer and use it in GitHub Desktop.
Save technetbytes/0842aa7dc70aab6830aca0690e5702b2 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 26 19:29:54 2015
@author: saqibullah
@email: saqibullah@gmail.com
"""
import urllib2
import getpass
from datetime import date, timedelta
def get_Username():
return getpass.getuser()
def get_Previousdate():
previous = date.today() - timedelta(1)
return previous.strftime('%y%m%d')
weblogfile = "access_{}.log".format(get_Previousdate())
print weblogfile
response = urllib2.urlopen("http://hopebuild.org/logs/"+weblogfile)
data = response.read()
filename = "/home/{}/Downloads/{}".format(get_Username(),weblogfile)
# Write web log data to file
with open(filename, 'w') as code:
code.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment