title: Parse request response for key, value pairs
body: <p>I'm storing the response from a POST request to Instagram's API into a text file. What's contained in this response is HTML, which includes an access token I'd like to dig out. The reason it's HTML is because this POST response is really meant to be dealt with by the end user, wherein they click a button and are then provided with the access code. However I need to do this on the backend, hence needing to deal with the HTML response. </p>
  
  <p>In any event, here's my code so far (real client ID is obscured for this post obviously): </p>
  
  <pre><code>OAuthURL = "https://api.instagram.com/oauth/authorize/?client_id=cb0096f08a3848e65f&amp;redirect_uri=https://www.smashboarddashboard.com/whathappened&amp;response_type=code"
  OAuth_AccessRequest = requests.post(OAuthURL).text 
  #print OAuth_AccessRequest
  
  with open('response.txt', 'w') as OAuthResponse:
          OAuthResponse.write(OAuth_AccessRequest.encode("UTF-8"))
  
  OAuthReady = open('response.txt', 'r')
  OAuthView = OAuthReady.read()
  print OAuthView 
  </code></pre>
  
  <p>What I'm left with after this is HTML stored in a text file. Among the HTML however are dictionaries, which I need to access the value, pairs for — some of it, for example, looks like this: </p>
  
  <pre><code>&lt;/div&gt; &lt;!-- .root --&gt;
  
      &lt;script src=//instagramstatic-a.akamaihd.net/bluebar/422f3d9/scripts/polyfills/es5-shim.min.js&gt;&lt;/script&gt;
  &lt;script src=//instagramstatic-a.akamaihd.net/bluebar/422f3d9/scripts/polyfills/es5-sham.min.js&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;window._sharedData = {"static_root":"\/\/instagramstatic-a.akamaihd.net\/bluebar\/422f3d9","entry_data":{},"hostname":"instagram.com","platform":{"is_touch":false,"app_platform":"web"},"qe":{"su":false},"display_properties_server_guess":{"viewport_width":360,"pixel_ratio":1.5},"country_code":"US","language_code":"en","gatekeepers":{"tr":false},"config":{"dismiss_app_install_banner_until":null,"viewer":null,"csrf_token":"2aedabf96ad1fe86fab0"},"environment_switcher_visible_server_guess":true};&lt;/script&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It's the string of numbers that is the value for the key "csfr_token" that I need to grab. What's the best approach for digging this out of the HTML that's stored in the txt file? </p>