title: BeautifulSoup output to .txt file
body: <p>I am trying to export my data as a .txt file</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import requests
  import os
  
  import os
  
  os.getcwd()
  '/home/folder'
  os.mkdir("Probeersel6") 
  os.chdir("Probeersel6")
  os.getcwd()
  '/home/Desktop/folder'
  os.mkdir("img")  #now `folder` 
  
  url = "http://nos.nl/artikel/2093082-steeds-meer-nekklachten-bij-kinderen-door-gebruik-tablets.html"
  r  = requests.get(url)
  soup = BeautifulSoup(r.content)
  data = soup.find_all("article", {"class": "article"})
  
  with open(""%s".txt", "wb" %(url)) as file:
      for item in data:
          print item.contents[0].find_all("time", {"datetime": "2016-03-16T09:50:30+0100"})[0].text 
          print item.contents[0].find_all("a", {"class": "link-grey"})[0].text
          print "\n"
          print item.contents[0].find_all("img", {"class": "media-full"})[0]
          print "\n"
          print item.contents[1].find_all("div", {"class": "article_textwrap"})[0].text
          file.write()
  </code></pre>
  
  <p>what should be put in the: </p>
  
  <pre><code>file.write()
  </code></pre>
  
  <p>to work?</p>
  
  <p>I am also trying to get the name of the .txt file the same as the url should I do that with a string?</p>
  
  <pre><code>with open(""%s".txt", "wb" %(url)) as file:
  </code></pre>
  
  <p><br></p>
  
  <pre><code>url = "http://nos.nl/artikel/2093082-steeds-meer-nekklachten-bij-kinderen-door-gebruik-tablets.html"
  </code></pre>