PHPLazy Posted May 17, 2019 Share Posted May 17, 2019 Hey Python Geeks, I need code to parse one access log file and show the ip address with count. The log file is : https://bureau-ehe.ch/logs/logs/access.log Anybody help me to parse the file in python? I want to track the repeated ips. Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted May 18, 2019 Share Posted May 18, 2019 Parse each line with a regular expression. According to that log, it looks like ([\d.]+) (\S+) (\S+) \[([^\]]+)\] "([^"]+)" (\d+) (\d+) "([^"]+)" "([^"]+)" Remote IP address Likely a hyphen HTTP Basic username if given Date/time Request URI HTTP response code Response length HTTP Referer if present HTTP User-Agent if present Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.