On my local windows machine, how do I write a script to download a comic every day and send it by email?

on my local windows machine, how can I write a script to download a comic every day and send it to myself via email?

e.g. http://comics.com/peanuts/

Update : I know how to upload an image to a file. the hard part is how to email it from my local windows machine.

+5
source share
6 answers

, . - - wget, Earwicker.

, , . Python - , - , urllib , . URL- .

XKCD, , :

#!/usr/bin/env python

import re, urllib

root_url = 'http://xkcd.com/'
img_url  = r'http://imgs.xkcd.com/comics/'

dl_dir   = '/path/to/download/directory/'

# Open the page URL and identify comic image URL
page  = urllib.urlopen(root_url).read()
comic = re.match(r'%s[\w]+?\.(png|jpg)' % img_url, page)

# Generate the filename
fname = re.sub(img_url, '', comic)

# Download the image to the specified download directory
try:
    image = urllib.urlretrieve(comic, '%s%s' % (dl_dir, fname))
except ContentTooShortError:
    print 'Download interrupted.'
else:
    print 'Download successful.'

, .

+8

feedburner RSS-, ?

+2

, , .

... , , URI, , , . HTML -, , URL- . , HTML- , mail() - :

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= " charset=iso-8859-1\r\n";

. , . HTTP- , .

+1

All Articles