8000 Fetching Internet data · neryuuk/learning-python@fbf19fe · GitHub
[go: up one dir, main page]

Skip to content

Commit fbf19fe

Browse files
committed
Fetching Internet data
1 parent 04b60f7 commit fbf19fe

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

Ch5 - Internet Data/inetdata_finished.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Ch5 - Internet Data/inetdata_start.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
#
2-
# Example file for retrieving data from the internet
3-
# LinkedIn Learning Python course by Joe Marini
4-
#
1+
import urllib.request
2+
53

64
def main():
7-
pass # this is a placeholder, do-nothing statement
5+
# open a connection to a URL using urllib2
6+
url = "https://google.com"
7+
weburl = urllib.request.urlopen(url)
8+
9+
# get the result code and print it
10+
print("GET {} {}".format(url, weburl.getcode()))
11+
12+
# read the data from the URL and print it
13+
data = weburl.read()
14+
print("PAYLOAD {}".format(data))
15+
816

917
if __name__ == "__main__":
1018
main()

0 commit comments

Comments
 (0)
0