Guest User

download_from_bing.py

a guest
May 7th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import ctypes
  2. import requests
  3. import os
  4.  
  5. class DownloadWallpaper(object):
  6.     def __init__(self):
  7.         r = requests.get('http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US')
  8.         data = r.json()
  9.         suffix = data['images'][0]['url']
  10.         wallpaper = requests.get("https://bing.com%s" % suffix)
  11.         with open("wallpaper.jpg", "wb") as wallpaperFile:
  12.             wallpaperFile.write(wallpaper.content)
  13.  
  14.  
  15. DownloadWallpaper()
Add Comment
Please, Sign In to add comment