Log Parsing with Regex

前端 未结 2 1171
你的背包
你的背包 2020-12-21 09:46

I\'m trying to parse an Apache Log with regex using Python and assign it to separate variables.

ACCESS_LOG_PATTERN = \'^(\\S+) (\\S+) (\\S+) \\[([\\w:/]+\\s[         


        
2条回答
  •  北海茫月
    2020-12-21 10:44

    import re
    
    
    HOST = r'^(?P.*?)'
    SPACE = r'\s'
    IDENTITY = r'\S+'
    USER = r'\S+'
    TIME = r'(?P

    RESULT

    ('180.76.15.30', '[24/Mar/2017:19:37:57 +0000]', 'GET /shop/page/32/?count=15&orderby=title&add_to_wishlist=4846 HTTP/1.1', '404', '10202')
    

提交回复
热议问题