1
00:00:04,890 --> 00:00:07,590
Creating a Tsipi client.

2
00:00:07,800 --> 00:00:08,610
Hello, everyone.

3
00:00:08,910 --> 00:00:13,040
Today, we're going to talk about how we can create a typical land.

4
00:00:13,260 --> 00:00:20,820
And I'm going to look into the TCAP client of a website and actually we're going to choose a famous

5
00:00:20,820 --> 00:00:21,320
website.

6
00:00:21,330 --> 00:00:23,010
So we were familiar with it.

7
00:00:23,370 --> 00:00:30,930
But in this video, we will look at the elements of the client before actually creating one and running

8
00:00:30,930 --> 00:00:32,110
the server over it.

9
00:00:32,490 --> 00:00:40,920
So if you go to Section six and create the new item file, let's write test VCP.

10
00:00:41,250 --> 00:00:48,440
OK, so here we are going to create the new file and I will import actually and get closer.

11
00:00:48,630 --> 00:00:54,690
I will import the circuit library of course, since we're working with it in discourse and then let's

12
00:00:54,690 --> 00:00:56,070
create some variable.

13
00:00:56,100 --> 00:01:04,000
So first of all, I will create a host which will be double, double, double the skilled army dot com.

14
00:01:05,180 --> 00:01:08,400
Then let's create the fourth variable.

15
00:01:08,490 --> 00:01:10,380
So first of all, create all the variables.

16
00:01:10,390 --> 00:01:15,440
And after that I will write the main function, which will use actually those variables.

17
00:01:15,900 --> 00:01:25,130
So the court will be 80, then the buffer size will be equal to four thousand and ninety six.

18
00:01:25,530 --> 00:01:34,530
And finally the address will be equal to our list of the host and the.

19
00:01:35,750 --> 00:01:36,950
First, OK.

20
00:01:38,030 --> 00:01:44,270
OK, so these are all the parameters who are going to use and let's create now our main function.

21
00:01:44,300 --> 00:01:54,590
So if name equals Main, then let's create a variable called Kalayaan Socket, and this will be called

22
00:01:54,590 --> 00:02:06,110
to a socket, that socket and inside our right socket dot a if a if I net.

23
00:02:06,230 --> 00:02:06,660
OK.

24
00:02:06,800 --> 00:02:07,360
And then.

25
00:02:08,590 --> 00:02:10,750
So kids dot.

26
00:02:11,610 --> 00:02:19,290
So extreme, and we usually write this in order to assess a Web page, then let's write client socket

27
00:02:19,290 --> 00:02:21,840
or a OK, how wrote it connect.

28
00:02:21,930 --> 00:02:27,630
And then we are going to pass the address, which consist of the hostname and the port.

29
00:02:27,660 --> 00:02:33,450
OK, this is everything needed for us to access certain server.

30
00:02:33,540 --> 00:02:35,980
OK, let's create now a while loop.

31
00:02:36,000 --> 00:02:37,260
So while.

32
00:02:38,320 --> 00:02:48,880
Through, OK, all right, data equals to get HTP 1.0.

33
00:02:50,440 --> 00:02:58,050
Backslash are backslash and backslash are backslash end, OK?

34
00:02:59,310 --> 00:03:00,340
And then if.

35
00:03:01,480 --> 00:03:03,550
Not there.

36
00:03:03,730 --> 00:03:07,440
So if we don't receive any data, we will break the world.

37
00:03:09,610 --> 00:03:21,010
And then they were right, client circuit dot sent and here I write the letter dot and called.

38
00:03:22,370 --> 00:03:31,450
And let's right then call principle, which is going to be the UTF eight, or does it actually then.

39
00:03:31,840 --> 00:03:32,990
All right, the data.

40
00:03:34,120 --> 00:03:34,790
Equals.

41
00:03:34,810 --> 00:03:40,210
So we're going to rewrite that their client socket that.

42
00:03:41,580 --> 00:03:52,870
Receive an eye right here the size that we inserted and if not there, then again, we're going to break

43
00:03:52,870 --> 00:03:53,670
the while loop.

44
00:03:53,830 --> 00:03:58,750
And finally, let's print the data that the call.

45
00:03:58,810 --> 00:04:04,270
So we're going to decode the data and then I'll write you T.F..

46
00:04:05,800 --> 00:04:06,820
Slash eight.

47
00:04:07,710 --> 00:04:08,090
OK.

48
00:04:09,650 --> 00:04:14,610
And then the right client socket dot clause.

49
00:04:14,840 --> 00:04:18,080
OK, so what is that code doing?

50
00:04:18,320 --> 00:04:19,740
Let's put a second call here.

51
00:04:20,030 --> 00:04:21,830
So what is that code doing?

52
00:04:22,190 --> 00:04:27,410
So first of all, when you provide all the parameters for the website we want to investigate, then

53
00:04:27,410 --> 00:04:34,260
we're creating the circuit to this website using its hostname import that is taught to the address here.

54
00:04:34,640 --> 00:04:40,040
And in this while loop, the only thing we're doing is assessing the data from the website.

55
00:04:40,370 --> 00:04:47,060
And here the data is going to be equal to the HTP representation of the website.

56
00:04:47,540 --> 00:04:51,590
And we say if we don't have the data, let's break the loop.

57
00:04:52,040 --> 00:04:54,140
But if we have data, we don't break.

58
00:04:54,590 --> 00:05:04,610
So if we actually have data, we are using the socket in order to send to the data from the server back

59
00:05:04,610 --> 00:05:13,550
to the client and the encoding this data with this principle, UTF eight and the data, the new data

60
00:05:13,550 --> 00:05:17,930
is going to be equal again to the socket.

61
00:05:17,940 --> 00:05:21,010
We're going to receive the data within the buffer size.

62
00:05:21,500 --> 00:05:24,320
And again, if there is no data, we'll break.

63
00:05:24,410 --> 00:05:30,650
And once we receive the data, we again want to decode this data because it's encoded.

64
00:05:30,650 --> 00:05:37,560
So we will not see any valuable information, but we're decoding it with the same principle here.

65
00:05:37,820 --> 00:05:39,620
So now we get the actual data.

66
00:05:39,650 --> 00:05:42,480
And finally, what we're doing, we are simply closing the socket.

67
00:05:42,950 --> 00:05:46,760
So let's go now to the terminal and let's actually run that code.

68
00:05:47,210 --> 00:05:47,620
That's right.

69
00:05:48,470 --> 00:05:51,370
And you can see that we have this impetus here.

70
00:05:51,380 --> 00:06:01,550
So if I write Python and then this GCP, not pure white, you can see that you are getting the HTML

71
00:06:01,550 --> 00:06:08,330
representation of this website, which is actually quite a long, long, long HTML.

72
00:06:08,540 --> 00:06:16,940
But this is proving that the data is actually being sent between the server and the client where the

73
00:06:16,940 --> 00:06:22,270
server is the actual site and the client is our computer, which is connected to Port eight.

74
00:06:22,820 --> 00:06:26,120
And for example, here I can even change the website.

75
00:06:26,330 --> 00:06:29,440
So let's do it as a Yahoo dot com.

76
00:06:29,810 --> 00:06:36,920
And if I do it, you can see that we are getting a different type of HTML client here, which is way

77
00:06:36,920 --> 00:06:39,050
more sort of comparing to mine, of course.

78
00:06:40,220 --> 00:06:47,000
But yes, you can actually type the website you want to get data from and you can obtain it quite easy

79
00:06:47,420 --> 00:06:49,280
using the sockets.

80
00:06:49,700 --> 00:06:53,990
So this is how you obtain data from Internet using sockets.

81
00:06:54,020 --> 00:07:00,950
Guys, thank you very much for watching that video and wait for the next one in which we are going to

82
00:07:00,950 --> 00:07:02,690
talk about Bonners.

83
00:07:02,900 --> 00:07:03,920
Thanks for watching.
