This file contains hidden or 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
| start_date = '2016-10-16' #@param {type:"date"} | |
| end_date = '2016-10-17' #@param {type:"date"} | |
| print('start date for the exported csv is: ' + start_date) | |
| print('end date for the exported csv is: ' + end_date) | |
| print ('') |
This file contains hidden or 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
| print ('FYI, the dataset spans the following time intervals:') | |
| print (df['Date'].min(), df['Date'].max()) |
This file contains hidden or 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
| #Define the function | |
| def reverse_dns(ip_address): | |
| ''' | |
| This method returns the true host name for a | |
| given IP address | |
| ''' | |
| host_name = socket.gethostbyaddr(ip_address) | |
| reversed_dns = host_name[0] | |
| return reversed_dns |
This file contains hidden or 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
| df['SEBotClass'] = pd.np.where(df.userAgent.str.contains("YandexBot"), "YandexBot", | |
| pd.np.where(df.userAgent.str.contains("bingbot"), "BingBot", | |
| pd.np.where(df.userAgent.str.contains("DuckDuckBot"), "DuckDuckGo", | |
| pd.np.where(df.userAgent.str.contains("Baiduspider"), "Baidu", | |
| pd.np.where(df.userAgent.str.contains("Googlebot/2.1"), "GoogleBot", "Else"))))) |
This file contains hidden or 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
| df['httpCodeClass'] = pd.np.where(df.httpCode.str.contains("^1.*"), 'Info (1XX)', | |
| pd.np.where(df.httpCode.str.contains("^2.*"), 'Success (2XX)', | |
| pd.np.where(df.httpCode.str.contains("^3.*"), 'Redirects (3XX)', | |
| pd.np.where(df.httpCode.str.contains("^4.*"), 'Client errors (4XX)', 'Server errors (5XX)')))) |
This file contains hidden or 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
| df = df[['IP','Date','Domain','Method','url','httpProto','httpCode','timeTaken','urlRef','userAgent','header']] | |
| df.rename(columns={"header": "redirURL"}, inplace=True) |
This file contains hidden or 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
| df[['remainder','header']] = df["header"].str.split('".*LOCATION=30.-', 1, expand=True) | |
| df['header'] = df['header'].str.replace('\"', '') |
This file contains hidden or 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
| df[['userAgent','header']] = df["header"].str.split("\" ", 1, expand=True) |
This file contains hidden or 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
| df[['urlRef','header']] = df["header"].str.split(" ", 1, expand=True) | |
| df['urlRef'] = df['urlRef'].str.replace('\"', '') |
This file contains hidden or 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
| df[['timeTaken','header']] = df["header"].str.split(" ", 1, expand=True) |