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, let's look at the builtins for Python 3, so here we can see that we've got basically
0:13 the same code that we use for Python 2 and I am going to just upgrade it to the Python 3 version.
0:18 So the first error, well, let me just show you actually, first of all, that we are running the Python 3 virtual environment
0:25 that we have been for most of this class so the first thing to notice is urllib2 is no longer a thing,
0:31 now there is a couple of choices, we have the errors that you might encounter, we have the request, we have the url parser,
0:38 and we have the robot parser as well as responses, what we are going to work with is just urllib.request for now,
0:45 alright, just like before, the first thing that we had to do was get the post
0:48 so let's come down here and you can see get post is not looking so hot right now, because there is no urllib2 but let's look inside urllib.request,
0:56 there is a url opener, it is similar, it's not the same, it's similar, it has more or less the same signature here,
1:06 and we can open the url, there we go, okay so we want to open it like this and from here on,
1:15 it looks pretty much the same, so get post is not going to be that different,
1:20 let's go and do a list here and look, we still have our post and everything, great.


Talk Python's Mastodon Michael Kennedy's Mastodon