fork download
  1. from sys import stdin
  2. import re
  3.  
  4.  
  5. logdata = stdin.read()
  6.  
  7. for item in re.finditer(r'''
  8. (?P<host>\d+\.\d+\.\d+.\d+)
  9. (?:[-\s]+)
  10. (?P<user_name>\w+\d)
  11. (?:[^[]+\[)
  12. (?P<time>[^]]+)
  13. (?:\][^]"]+")
  14. (?P<request>[^"]+)''',
  15. logdata, re.VERBOSE):
  16. print(item.groupdict())
Success #stdin #stdout 0.01s 7388KB
stdin
146.204.224.152 - feest6811 [21/Jun/2019:15:45:24 -0700] "POST /incentivize HTTP/1.1" 302 4622
stdout
{'user_name': 'feest6811', 'host': '146.204.224.152', 'request': 'POST /incentivize HTTP/1.1', 'time': '21/Jun/2019:15:45:24 -0700'}