old_contents: #coding=utf8
  #python 2.7
  #auther StrayBugs
  
  import urllib, cStringIO
  import re, os
  from time import sleep
  # need PIL & pywin32 installed
  import Image
  from ctypes import windll
  
  SCREEN_RESOLUTION = '1366x768'
  
  BMP_PATH = 'bing.wallpaper-straybugs.bmp'
  BING_URL = 'http://cn.bing.com'
  link_checker = re.compile(r"g_img=.*?\'(.*?)\'")
  
  if os.path.isfile(BMP_PATH):
    windll.user32.SystemParametersInfoA(20, 0, BMP_PATH, 0)
  
  for c in range(100):
    try:
      pageData = urllib.urlopen(BING_URL).read()
      link = link_checker.search(pageData).group(1).replace('1920x1080', SCREEN_RESOLUTION)
      break
    except: 
      sleep(10)
      continue
    else: exit(1)
  
  picdata = cStringIO.StringIO(urllib.urlopen(link).read())
  Image.open(picdata).save(BMP_PATH, 'BMP')
  windll.user32.SystemParametersInfoA(20, 0, BMP_PATH, 0)
new_contents: #coding=utf8
  #python 2.7
  #auther StrayBugs
  
  import urllib, cStringIO
  import re, os
  from time import sleep
  # need PIL & pywin32 installed
  import Image
  from ctypes import windll
  
  SCREEN_RESOLUTION = '1366x768'
  COLLECTIONS_PATH = 'F:\\PHOTO\\BingWallPapers'
  BMP_CACHE_FILE = 'bing.wallpaper-straybugs.bmp'
  BING_URL = 'http://cn.bing.com'
  link_checker = re.compile(r"g_img=.*?\'(.*?)\'")
  
  if os.path.isfile(BMP_CACHE_FILE):
    windll.user32.SystemParametersInfoA(20, 0, BMP_CACHE_FILE, 0)
  
  for c in range(100):
    try:
      pageData = urllib.urlopen(BING_URL).read()
      originLink = link_checker.search(pageData).group(1)
      break
    except: 
      sleep(10)
      continue
    else: exit(1)
  
  originLink = BING_URL + originLink
  
  downloadLink = originLink.replace('1920x1080', SCREEN_RESOLUTION)
  picdata = cStringIO.StringIO(urllib.urlopen(downloadLink).read())
  Image.open(picdata).save(BMP_CACHE_FILE, 'BMP')
  windll.user32.SystemParametersInfoA(20, 0, BMP_CACHE_FILE, 0)
  
  # Save file for collecting
  if not os.path.isdir(COLLECTIONS_PATH):
    os.makedirs(COLLECTIONS_PATH)
  originPicName = originLink.split('?')[0].split('/')[-1]
  originPicPath = os.path.join(COLLECTIONS_PATH, originPicName)
  if not os.path.isfile(originPicPath):
    urllib.urlretrieve(originLink, originPicPath)
subject: update bing wallpaper setter