Welcome back, the request module provides a function get and that's your Python program fetch the content of a web page. On line 1, I've imported the request module. And on line 4, I'm invoking the get function from the request module. You pass in the URL, and you get back a response object that includes the text, the source of the page that lives at that URL. In the Runestone environment, we've implemented a very limited version of the request module. The response object that you get back only has some of the attributes that you would have in a full Python implementation. And our request module will only work for fetching from some sites. In particular, you can't use it to fetch regular html pages like umich.edu. And the reason is that there are security considerations built into most web browsers called cross site scripting restrictions. But there are exceptions to those restrictions for websites that are meant to provide data, basically for APIs. So we'll illustrate how to use requests.get. So we'll illustrate how to use requests.get with one of those APIs. First, let's see in a browser what's available at this data muse API. Here's the full URL, https://api.datamuse.com /words?rel_rhy=Funny. I've copied that URL into another browser tab, let's see what we get back. We get, in JSON format, a list of dictionaries. Each of the dictionaries tells us one word like money, or honey, or sunny, or bunny all words that rhyme with funny. So this a search we've done for words that rhyme with funny. Now, let's see how we can fetch that same data in our Python program. Basically, I just import requests, that's the requests module, it makes it available, On line 4, I'm invoking requests.get, passing in that whole URL. What I get back is a response object. I save that in the variable page, and the type of page we're going to find out it's a response object, and we're going to be able to ask for various attributes. The text attribute will give us the contents, all of those rows like money and sunny. So let's run this and see what we get. You can see that when we print out the type, it's a response object. If we ask to print out the first 150 characters of the text, we see that it's word, money and word honey and so on in that JSON format. I can ask to print the URL. That's where the data was fetch from, in our case, it's not very interesting as it's exactly the URL we passed in. But we're going to see a little later that the requests.get function can construct a more complicated URL on our behalf. And then it's nice to be able to see what it constructed for us There's a method for that response object called .json. And you can tell it's a method, we have to invoke it with the open-close parentheses. It takes the contents of the text, that's that stuff, and it just passes it through json.loads. This is just a shorthand for saying json.loads@page.text. And that will take this text string and turn it into a Python object and in our case, a list of dictionaries. I've asked what the type is, and it's a list. If I ask for the very first item in that list, its a dictionary. And if I want to see the whole thing, I can dump it back to a string with the indent equals 2 parameter to make it print nice and pretty for us. You can see that it pretty printed it for us all down here. Now in a full implementation of Python, the response object would have some other useful attributes besides just .text and .url. In the textbook, we go into some of those extra attributes, but I'm not going to cover them in these videos. You've now seen the basics of the requests module. You pass in the URL, you get back a response object. With that response object, you can ask for its .text attribute or you can call a statJson method to have the text contents turned into a Python list or dictionary. There's a more advanced use of the request module where it helps you construct the URL out of parts and you'll see that in a future lesson. So long for now. See you next time.