I have extracted the data. Its being printed on the command line but I want to save that to a text file. I tried doing that and the text file gets created but that's empty.
Here is my code, please tell me what to add in my code so that I can save the scraped data to a text file.
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen(url).read()
soup = BeautifulSoup(page, "lxml")
for tr in soup.find_all('tr')[1:]:
tds = tr.find_all('th')
tds = tr.find_all('td')
print "Nome: %s, Cognome: %s, Email: %s\n" % \
(tds[0].text, tds[1].text, tds[2].text)