Skip to content

Instantly share code, notes, and snippets.

@toumorokoshi
Created May 15, 2013 00:14
Show Gist options
  • Save toumorokoshi/5580763 to your computer and use it in GitHub Desktop.
Save toumorokoshi/5580763 to your computer and use it in GitHub Desktop.
Small scraper for project365photos
from BeautifulSoup import BeautifulSoup
import urllib2
import requests
import re
import os
photo_url_match = re.compile("^http://.*photos.*amazonaws.*photos.*png")
target_directory = "/tmp/"
html = urllib2.urlopen("YOURIPHONEPROJECT_URL_HERE").read()
parsed = BeautifulSoup(html)
links = parsed.findAll("a")
def download_file(url, output_url):
r = requests.get(url)
target_path = os.path.join(target_directory, output_url)
print "Downloading %s to %s..." % (url, target_path)
with open(target_path, "w+") as image:
image.write(r.content)
i = 1
for l in links:
if l.get('class') == "lightbox":
download_file(l.get('href'), "%s.png" % str(i))
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment