Advertisement
Guest User

interfacelift 2880x900

a guest
Apr 22nd, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import os, urllib2, re, sys, commands, random, time
  3.  
  4. # -- Changable Variables
  5. url = 'http://interfacelift.com/wallpaper/downloads/date/2_screens/2880x900/' #Browse to the page that has all the wallpaper you want and paste here
  6. directory = '/home/user/wallpaper/2880x900' #Path to download to
  7. stoponfind = '1' # Set to 0 to download all files even if the file exists and 1 to stop when it finds where it left off
  8. wgetpath = '/usr/bin/wget' #Default on linux systems /usr/local/bin/wget on freebsd
  9.  
  10. # -- Should not need to edit below here unless something stops working --
  11. useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)' #Fake useragent since wget is blocked
  12. pattern = '(?<=<a href=")/wallpaper/.*jpg(?=">)' # The regex pattern used to look up picture url paths
  13. picturepattern = '[^/]*$' # The regex pattern to pull picture filename to see if file exists
  14. wallpapercount = 0
  15. count = 1
  16.  
  17. while count < 9999999:
  18. headers = { 'User-Agent' : useragent }
  19. request = urllib2.Request(url + "index" + str(count) + ".html", None, headers)
  20. data = urllib2.urlopen(request).read()
  21. pictures = re.findall(pattern, data)
  22. urlcount = len(pictures)
  23. for picture in pictures:
  24. m = re.search(picturepattern, picture)
  25. picturefile=m.group()
  26. if os.path.exists(directory + "/" + picturefile):
  27. if stoponfind == "1":
  28. print 'Directory up to date. Downloaded ' + str(wallpapercount) + ' new wallpaper.'
  29. quit()
  30. status, output = commands.getstatusoutput(wgetpath + ' -P ' + directory + ' --random-wait -nc -U "' + useragent + '" ' + 'http://interfacelift.com' + picture)
  31. if status == 0:
  32. print str(wallpapercount) + '. Downloaded http://interfacelift.com' + picture + ' ...'
  33. else:
  34. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  35. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WGET OUTPUT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  36. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  37. print '----------------------------------------------------------------------------------'
  38. print output
  39. print '----------------------------------------------------------------------------------'
  40. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  41. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  42. print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  43. print str(wallpapercount) + '. DOWNLOAD FAILED check wget output above for reason.'
  44. print 'Exiting script ... wget returned non 0 exit status code: ' + str(status)
  45. quit()
  46. wallpapercount += 1
  47. if urlcount == 0:
  48. print "Downloaded " + str(wallpapercount) + " wallpaper from InterfaceLift."
  49. randomnum = random.randint(5,10)
  50. print 'Sleeping for :' + str(randomnum)
  51. quit()
  52. count += 1
  53. randomnum = random.randint(10,30)
  54. print 'Sleeping for :' + str(randomnum)
  55. time.sleep(randomnum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement