by using Python, i want to pickup the news titles on http://www.boston.com/yourtown/ and save them into a .txt file.
i have 2 questions:
1. how can i have the codes run every 2 hours?
2. how can i have the outputs write into a .txt file?
from bs4 import BeautifulSoup import re import urllib2 url = "http://www.boston.com/yourtown/" page = urllib2.urlopen(url) soup = BeautifulSoup(page.read()) news_titles = soup.find_all('h4') for nts in news_titles: for n in nts("a"): print n.renderContents()