I am trying to download some images from MomentumDash (for educational purpose only). I have written the following python code:
import urllib
import os
import random
#Chooses an image between 1 to 14
choice=random.randint(01,14)
print choice
#Downloads images
a=urllib.urlretrieve("http://ift.tt/2knU8BZ"+"%02d" % (choice,)+".jpg", str(choice)+".jpg")
print a #Tells the image
#Getting the location of the saved image
cwd = os.getcwd()
random=random.choice(os.listdir(cwd))
file =cwd+ '\\' +random
#Making the image to desktop image
import ctypes
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER , 0, file, 3)
The thing is the probability of this progrm to set a image is 1/7 ish.
Most of the times it gives a black background screen.
Where am I wrong?
Aucun commentaire:
Enregistrer un commentaire