title: generate and open HTML string with webbrowser without accessing disc
body: <p>I want to create a HTML file in my code and open a new tab in chrome with it.</p>
  
  <p>this is the code I have. It works:</p>
  
  <pre><code>with open('mysite.html','w') as f:
      f.write('&lt;html&gt;')
      f.write('&lt;head&gt;')
      f.write('&lt;title&gt;Table of contents&lt;/title&gt;')
      f.write('&lt;/head&gt;')
      f.write('&lt;body&gt;')
      # myhtmltable is a pandas dataframe containing only text 
      f.write(myhtmltable)
      f.write('&lt;/body&gt;')
      f.write('&lt;/html&gt;')
  
  chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
  
  webbrowser.get(chrome_path).open('mysite.html')
  </code></pre>
  
  <p>As you can see I create a file in the local folder where the .py lives. </p>
  
  <p>Is it possibly to create the HTML file on the fly and not having to access the disc, i.e. saving the file and reading it with webbrowser?</p>
  
  <p>So If I have something like:</p>
  
  <pre><code>myhtml = '&lt;html&gt;&lt;head&gt;&lt;title&gt;Table of contents&lt;/title&gt;&lt;/head&gt;&lt;body&gt;this is the body&lt;/body&gt;&lt;/html&gt;'
  </code></pre>
  
  <p>can I send it directly to a chrome tab?</p>
  
  <p>Here there are two solutions but both creating a local file:
  <a href="https://stackoverflow.com/questions/21437386/launch-html-code-in-browser-that-is-generated-by-beautifulsoup-straight-from-p">Launch HTML code in browser (that is generated by BeautifulSoup) straight from Python</a></p>