I did notice that if you access bing.com from a USA IP address then you have the ability to retrieve a higher resolution 1920x1200 image, whereas from the UK (and likely elsewhere) you can only access the 1366x768 image.
import re
import urllib2
import os
import shutil
import sys
bing_url = 'http://www.bing.com'
save_location = sys.argv[1]
p = re.compile('/az/.+?(jpg)')
resp = urllib2.urlopen(bing_url).read()
image_url = p.search(resp).group()
if '_EN-US' in image_url:
res = image_url.split('_')
extension = image_url.split('.')[-1]
image_url = '_'.join(res[:-1]) + '_1920x1200.' + extension
try:
img = urllib2.urlopen(bing_url + image_url)
except urllib2.HTTPError as e:
print e
sys.exit(-1)
image_name = image_url.split('/')[-1]
if not os.path.exists(save_location):
os.makedirs(save_location)
with open(save_location + image_name, 'wb') as f:
shutil.copyfileobj(img, f)
Edit: I have since updated this script with some nice new changes. You can find that post here: https://ryanmcconville.com/blog/post/bing-image-retrieval-v2/