-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
28 lines (24 loc) · 782 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import requests
from bs4 import BeautifulSoup
from objects import Album
def get_albums_from_user(user):
"""Given the URL of a Webshots user's profile page on archive.org,
return a list of albums"""
albums = []
host = 'http://web.archive.org'
url = '{0}/web/20121108151000/http://community.webshots.com/user/{1}' \
.format(host, user)
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
lis = soup.find_all('li', {'class': 'album'})
for li in lis:
a = li.h4.a
album = Album(a.get('href'))
albums.append(album)
return albums
if __name__ == '__main__':
user = os.environ['WEBSHOTS_USER']
albums = get_albums_from_user(user)
for album in albums:
album.save_images()