title: Beautiful Soup - Export to Text File
body: <p>I'm trying beautiful soup, and I want to export it into a text file.</p>
  
  <p>How to change the <code>result.txt</code> file name into the text from <code>soup.find(class_="entry-title").get_text()</code>?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>from bs4 import BeautifulSoup as bs
  import urllib.request
  
  #getting the page.
  url = urllib.request.urlopen('http://www.haripuisi.com/arsip/3163').read()
  soup = bs(url, 'lxml')
  
  #extracting the content.
  print (soup.find(class_="entry-title").get_text())
  print (soup.find(class_="entry-content").get_text())
  
  #save into text file.
  save_file = open(r'C:\Users\Denis\Desktop\tempting texting\result.txt', 'w')
  save_file.write(soup.find(class_="entry-content").get_text())
  save_file.close()
  </code></pre>