title: Scraping urls from html, save in csv using BeautifulSoup
body: <p>I'm trying to save all hyperlinked urls in an online forum in a CSV file, for a research project.</p>
  
  <p>When I 'print' the html scraping result it seems to be working fine, in the sense that it prints all the urls I want, but I'm unable to write these to separate rows in the CSV.</p>
  
  <p>I'm clearly doing something wrong, but I don't know what! So any help will be greatly appreciated.</p>
  
  <p>Here's the code I've written:</p>
  
  <pre><code>import urllib2
  from bs4 import BeautifulSoup
  import csv
  import re
  
  soup = BeautifulSoup(urllib2.urlopen('http://forum.sex141.com/eforum/forumdisplay.php?    fid=28&amp;page=5').read())
  
  urls = []
  
  for url in soup.find_all('a', href=re.compile('viewthread.php')):
          print url['href']
  
  csvfile = open('Ss141.csv', 'wb')
  writer = csv.writer(csvfile)
  
  for url in zip(urls):
          writer.writerow([url])
  
  csvfile.close()
  </code></pre>