Files
ferglie/core/bing.py
Fergal Moran 4333677844 Initial commit
2017-05-03 21:31:11 +01:00

13 lines
363 B
Python
Executable File

from urllib.request import urlopen
from xml.etree.ElementTree import parse
BASE_URL = 'http://www.bing.com/'
IOTD_URL = BASE_URL + 'HPImageArchive.aspx?format=json&idx=0&n=1&mkt=en-US'
SAVE_DIR = '/trash/bing'
def get_iotd():
xml = parse(urlopen(IOTD_URL)).getroot()
u = xml.findall('./image/url')[0]
return "%s%s" % (BASE_URL, u.text)