Creating a Tsipi client.
Hello, everyone.
Today, we're going to talk about how we can create a typical land.
And I'm going to look into the TCAP client of a website and actually we're going to choose a famous
website.
So we were familiar with it.
But in this video, we will look at the elements of the client before actually creating one and running
the server over it.
So if you go to Section six and create the new item file, let's write test VCP.
OK, so here we are going to create the new file and I will import actually and get closer.
I will import the circuit library of course, since we're working with it in discourse and then let's
create some variable.
So first of all, I will create a host which will be double, double, double the skilled army dot com.
Then let's create the fourth variable.
So first of all, create all the variables.
And after that I will write the main function, which will use actually those variables.
So the court will be 80, then the buffer size will be equal to four thousand and ninety six.
And finally the address will be equal to our list of the host and the.
First, OK.
OK, so these are all the parameters who are going to use and let's create now our main function.
So if name equals Main, then let's create a variable called Kalayaan Socket, and this will be called
to a socket, that socket and inside our right socket dot a if a if I net.
OK.
And then.
So kids dot.
So extreme, and we usually write this in order to assess a Web page, then let's write client socket
or a OK, how wrote it connect.
And then we are going to pass the address, which consist of the hostname and the port.
OK, this is everything needed for us to access certain server.
OK, let's create now a while loop.
So while.
Through, OK, all right, data equals to get HTP 1.0.
Backslash are backslash and backslash are backslash end, OK?
And then if.
Not there.
So if we don't receive any data, we will break the world.
And then they were right, client circuit dot sent and here I write the letter dot and called.
And let's right then call principle, which is going to be the UTF eight, or does it actually then.
All right, the data.
Equals.
So we're going to rewrite that their client socket that.
Receive an eye right here the size that we inserted and if not there, then again, we're going to break
the while loop.
And finally, let's print the data that the call.
So we're going to decode the data and then I'll write you T.F..
Slash eight.
OK.
And then the right client socket dot clause.
OK, so what is that code doing?
Let's put a second call here.
So what is that code doing?
So first of all, when you provide all the parameters for the website we want to investigate, then
we're creating the circuit to this website using its hostname import that is taught to the address here.
And in this while loop, the only thing we're doing is assessing the data from the website.
And here the data is going to be equal to the HTP representation of the website.
And we say if we don't have the data, let's break the loop.
But if we have data, we don't break.
So if we actually have data, we are using the socket in order to send to the data from the server back
to the client and the encoding this data with this principle, UTF eight and the data, the new data
is going to be equal again to the socket.
We're going to receive the data within the buffer size.
And again, if there is no data, we'll break.
And once we receive the data, we again want to decode this data because it's encoded.
So we will not see any valuable information, but we're decoding it with the same principle here.
So now we get the actual data.
And finally, what we're doing, we are simply closing the socket.
So let's go now to the terminal and let's actually run that code.
That's right.
And you can see that we have this impetus here.
So if I write Python and then this GCP, not pure white, you can see that you are getting the HTML
representation of this website, which is actually quite a long, long, long HTML.
But this is proving that the data is actually being sent between the server and the client where the
server is the actual site and the client is our computer, which is connected to Port eight.
And for example, here I can even change the website.
So let's do it as a Yahoo dot com.
And if I do it, you can see that we are getting a different type of HTML client here, which is way
more sort of comparing to mine, of course.
But yes, you can actually type the website you want to get data from and you can obtain it quite easy
using the sockets.
So this is how you obtain data from Internet using sockets.
Guys, thank you very much for watching that video and wait for the next one in which we are going to
talk about Bonners.
Thanks for watching.