So here we are, back with our code. Now, the
only new stuff that I have added to the code
thus far, is this function called, check_profanity, by the way,
this function is empty for now. It takes in, one argument,
or one piece of information, which is the text we
actually want to check for profanity. Now, I know there
is this module in Python called, URL lib, which helps
us get information from the internet. It, has a function called,
URL open, which takes in a link to a website.
So here, I'm going to give it the full link,
to the the what do you love website. [SOUND] And
add to that the text we actually want to check for
profanity. [SOUND] Now, this function URL open. Is going to
help us make a connection, to this website. So, I'm going
to call this, [SOUND] connection. Now I recognize that you
may not be able to read the entire line of code
that we've written here, so I'm going to temporarily, put
in a return statement there. So you can read the
whole line of code. And then I'm going to restore
the code. Okay, let's continue. Now, I want us to
notice, that this function URL open, is quite similar to
the other function that we have used in this program,
which is open. Open, helps us read contents from a
file on our computer. URL open on the other hand,
helps open a connection to a website on the internet. Then we
can do things with that connection. Things like, read a response from
that website. [SOUND] I'm going to call this response, output, and then print
the output. After I've done that, [SOUND] I will close the connection.
So now, it's time for us to call this
function check_profanity, and I will do that after I have
successfully read the text from a file on my
computer. [SOUND] So, let me add code to call the
function, check_profanity, and to it, I will pass in
the contents that we previous read from the file. I
am going to save our program. Now if all
goes well, the read_text function, will read the contents from
the movie_quotes file, and then the check_profanity function,
will check that text for curse words. Let me
run my program and oh, it seems like, I forgot to import URL lib. So let me go
back to the code and add that to the very top. [SOUND] There it is. Let me
save my program, and run again. And this time,
the program worked and the programs response is false,
which means that the movie quotes, have no
curse words in them. Now, if I go back
to my movie quotes file. And change just one
word, let me save this file. And run my
code one more time. Now the response changes to
true, which means that there was a curse word
in our movie codes file. Alright, so it seems
like we're getting very close to finishing this code.
But before we do, [SOUND] I want us to figure out. How
Python knows about this think URL lib and URL open, lets find out.