#!/usr/bin/python import os import re from urllib import urlopen # TO DO: # Keep track of what has already been sent. # INPUTS: subscribers='dvlink@gmail.com' location = 'wch' search_term = 'guitar' #search_term = 'ipod' #search_term = 'macbook' href_base = "http://newyork.craigslist.org" url='%s/search/sss/%s?query=%s' % (href_base, location, search_term) email_filename = 'email_body.txt' # GO TO TOWN: #x = re.compile('.*') page = urlopen(url).read() ps = page.split('') report = "" fp = open(email_filename, 'w') fp.write('\n
\n') for p in ps: m = re.match(r'.*
(.*) - (.*)', p)
if m and len(m.groups()) == 3:
mon_day = m.group(1)
href = m.group(2)
desc = m.group(3)
fp.write('%s - %s
\n' % \
(mon_day, href_base, href, desc))
fp.write('