Skip to content

Commit 240de58

Browse files
author
Bill Lubanovic
committed
Updates for the third release.
1 parent 0fc63cf commit 240de58

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Introducing Python
22
=================
33

44
This repository contains the programs featured in _Introducing Python_.
5+
Some examples have been updated for the second and third printings.
56

67
|directory|chapter|
78
|---|---|

intro/archive.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import webbrowser
2+
import json
3+
from urllib.request import urlopen
4+
5+
print("Let's find an old website.")
6+
site = input("Type a website URL: ")
7+
era = input("Type a year, month, and day, like 20150613: ")
8+
url = "http://archive.org/wayback/available?url=%s&timestamp=%s" % (site, era)
9+
response = urlopen(url)
10+
contents = response.read()
11+
text = contents.decode("utf-8")
12+
data = json.loads(text)
13+
try :
14+
old_site = data["archived_snapshots"]["closest"]["url"]
15+
print("Found this copy: ", old_site)
16+
print("It should appear in your browser now.")
17+
webbrowser.open(old_site)
18+
except :
19+
print("Sorry, no luck finding", site)

intro/archive2.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import webbrowser
2+
import requests
3+
4+
print("Let's find an old website.")
5+
site = input("Type a website URL: ")
6+
era = input("Type a year, month, and day, like 20150613: ")
7+
url = "http://archive.org/wayback/available?url=%s&timestamp=%s" % (site, era)
8+
response = requests.get(url)
9+
data = response.json()
10+
try :
11+
old_site = data["archived_snapshots"]["closest"]["url"]
12+
print("Found this copy: ", old_site)
13+
print("It should appear in your browser now.")
14+
webbrowser.open(old_site)
15+
except :
16+
print("Sorry, no luck finding", site)

0 commit comments

Comments
 (0)