Created
June 14, 2016 09:42
-
-
Save technetbytes/0842aa7dc70aab6830aca0690e5702b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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