-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_gaerpytz.py
More file actions
21 lines (17 loc) · 735 Bytes
/
Copy pathinstall_gaerpytz.py
File metadata and controls
21 lines (17 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import StringIO
import zipfile
import requests
from bs4 import BeautifulSoup
# Get HTML of the gaerpytz home page
gaerpytz_url = "https://gaerpytz.appspot.com"
gaerpytz_webpage = requests.get(gaerpytz_url)
gaerpytz_html = gaerpytz_webpage.text
# Parse HTML to get the zipfile's download link
soup = BeautifulSoup(gaerpytz_html, "html.parser")
zip_href = soup.find(title="Download the latest build").get("href")
zip_url = gaerpytz_url + zip_href
# Download the zipfile and extract it to the lib folder. The zipfile contains
# the module folder for pytz and will overwrite the one currently in lib
request = requests.get(zip_url, stream=True)
zip_file = zipfile.ZipFile(StringIO.StringIO(request.content))
zip_file.extractall("lib")