title: Exporting Python Scraping Results to CSV
body: <p>The code below is yielding a value for the "resultStats" ID, which I would like to save in a CSV file. Is there any smart way to have the " desired_google_queries" (i.e. the search terms) in column A and the "resultStats" values in column B of the CSV?</p>
  
  <p>I saw that there are a number of threads on this topic but none of the solutions I have read through worked for the specific situation.</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import urllib.request
  import csv
  
      desired_google_queries = ['Elon Musk' , 'Tesla', 'Microsoft']
  
  for query in desired_google_queries:
  
      url = 'http://google.com/search?q=' + query
  
      req = urllib.request.Request(url, headers={'User-Agent' : "Magic Browser"})
      response = urllib.request.urlopen( req )
      html = response.read()
  
      soup = BeautifulSoup(html, 'html.parser')
  
      resultStats = soup.find(id="resultStats").string
      print(resultStats)
  </code></pre>