Consuming HTTP Services in Python Transcripts
Chapter: HTTP services with Python builtins
Lecture: Python 3: Blog explorer: Getting posts with urllib.request

Login or purchase this course to watch this video and the rest of the course contents.
0:01 So we've seen Python 2 and urllib2 in action,
0:05 let's look at the builtins for Python 3,
0:08 so here we can see that we've got basically
0:12 the same code that we use for Python 2
0:14 and I am going to just upgrade it to the Python 3 version.
0:17 So the first error, well, let me just show you actually, first of all,
0:21 that we are running the Python 3 virtual environment
0:24 that we have been for most of this class
0:27 so the first thing to notice is urllib2 is no longer a thing,
0:30 now there is a couple of choices, we have the errors that you might encounter,
0:34 we have the request, we have the url parser,
0:37 and we have the robot parser as well as responses,
0:40 what we are going to work with is just urllib.request for now,
0:44 alright, just like before, the first thing that we had to do was get the post
0:47 so let's come down here and you can see get post is not looking so hot right now,
0:52 because there is no urllib2 but let's look inside urllib.request,
0:55 there is a url opener, it is similar, it's not the same, it's similar,
1:00 it has more or less the same signature here,
1:05 and we can open the url, there we go,
1:10 okay so we want to open it like this and from here on,
1:14 it looks pretty much the same, so get post is not going to be that different,
1:19 let's go and do a list here and look, we still have our post and everything, great.