title: Regex to get URL from log file and store it in a dictionary in Python
body: <pre><code>import re
  
  filename = &quot;access.log&quot;
  
  path = &quot;&quot;
  
  with open (path + filename, &quot;r&quot;) as logfile:
    count = 0
    for line in logfile:                            # Loops through the log file
      regex = ('(?:(GET|POST) )(\S+)')              # Stores the regex
      url = re.findall(regex, line)                 # Uses the findall method and stores it in url variable
      print(url[0][1])                              # Prints out a list of URLs
  
  </code></pre>
  <p>This is an example of the log file</p>
  <p>access.log</p>
  <p>209.160.24.63 - - [01/Feb/2021:18:22:17] <strong>&quot;GET /product.screen?productId=BS-AG-G09&amp;JSESSIONID=SD0SL6FF7ADFF4953</strong> HTTP 1.1&quot; 200 2550 &quot;http://www.google.com/productid=12wdef&quot; &quot;Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5&quot; 422</p>
  <p>I got the URL in bold but I want to split it up now and store it in a dict in python.</p>