Skip to content

Instantly share code, notes, and snippets.

@nickedes
Created October 6, 2014 15:58
Show Gist options
  • Save nickedes/fb0402b6aeb99a870ba0 to your computer and use it in GitHub Desktop.
Save nickedes/fb0402b6aeb99a870ba0 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
import os
import urllib
def getPic():
url = "http://wayback.archive.org/web/20100814190317/http://www.rci.rutgers.edu/~jbass/courses/402/402_mcguire_here.htm"
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
results = soup.findAll("img")
count = 1
for r in results :
#print "%(src)s" % r
#file_dest = r["src"].split("/")[-1]
post = os.path.join('', str(count) + ".jpg")
with open(post, 'w') as f:
if r["src"].lower().startswith("/web/2010"):
x = r["src"].split('/http')[-1]
url = 'http'+ x
#print url
urllib.urlretrieve(url, post)
count = count + 1
#else:
# urllib.urlretrieve(urlparse.urlunparse(parsed), path)
#give paramter in method getpic() to download images.
getPic()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment