fork download
  1. #!/usr/bin/env python
  2.  
  3. import urllib2, sys, re, os
  4.  
  5. def main(args):
  6. if len(args) == 1:
  7. url = args[0]
  8. else:
  9. return 1
  10.  
  11. urls = []
  12. p = re.compile('\".*\.jpg\"')
  13.  
  14. for l in urllib2.urlopen(url):
  15. l = l.rstrip()
  16. result = re.findall(p, l)
  17. for r in result:
  18. for s in r.split():
  19. if re.search(p, s):
  20. s = s.replace('href=', '')
  21. s = s.replace('src=', '')
  22. s = s.replace('"', '')
  23. s = s.replace('ime.nu/', '')
  24. urls.append(s)
  25.  
  26. for url in urls:
  27. try:
  28. img = urllib2.urlopen(url)
  29. except:
  30. continue
  31. imgdata = img.read()
  32. if 20000 > len(imgdata): continue
  33. fp = open(os.path.basename(url), 'w')
  34. fp.write(imgdata)
  35. fp.close()
  36. img.close()
  37.  
  38. if __name__ == "__main__":
  39. sys.exit(main(sys.argv[1:]))
  40.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty