title: Why does my write() print a blank text file rather than the content - webscraper
body: <p>My code is returning a blank text file without the items which should be printed in the file. Running the file in anaconda, the text prints inside the file, so I don't think it is a problem with the retrieval, but something wrong with my write() code. I am new to python, any help would be well received. Thanks in advance.</p>
  
  <pre><code>import bs4 
  from urllib.request import urlopen as uReq
  from bs4 import BeautifulSoup as soup 
  
  my_url = 'https://www.globaltimes.cn/content/1190338.shtml'
  
  # opening up connection, grabbing the page
  uClient = uReq(my_url)
  page_html = uClient.read()
  uClient.close()
  
  #html parser
  page_soup = soup(page_html, "html.parser")
  
  #grabs each news item
  page_soup.findAll("div",{"class":"span12 row-content"})
  
  containers = page_soup.findAll("div",{"class":"span12 row-content"})
  
  filename = "first chinese scrape.txt"
  f = open ('D:/myfirstpython.txt',"w")
  
  headers = "data"
  
  f.write(page_soup.findAll("div",{"class":"span12 row-content"})
  )
  
  f.write('containers')
  f.close() 
  </code></pre>
  
  <p>I tried another method through this, but it still yielded a blank text file. </p>
  
  <pre><code>from newspaper import Article
  import nltk
  nltk.download('punkt')
  url= 'https://www.globaltimes.cn/content/1190338.shtml'
  article = Article(url, language="en") # en for English 
  
  article.download()
  article.parse()
  article.nlp()
  
  print("Article Title:") 
  print(article.title) #prints the title of the article
  print("\n") 
  print("Article Text:") 
  print(article.text) #prints the entire text of the article
  
  file1=open("NewsFile2.txt", "wt")
  file1.write("Title:\n")
  file1.write(article.title)
  file1.write('Article Text:')
  file1.write(article.text)
  file1.close()
  </code></pre>