1 00:00:05,270 --> 00:00:08,500 Working with Forbes, hello, everyone. 2 00:00:08,720 --> 00:00:16,100 Since you covered most of the topics related to how to send the request to a server and see some content 3 00:00:16,100 --> 00:00:19,820 from different bureaus, today I want to talk about forms. 4 00:00:20,420 --> 00:00:30,020 In order to use forms, we need to look at the post method from the Python packages in order to submit 5 00:00:30,020 --> 00:00:35,370 a user input from HTML file or to upload certain files to a server. 6 00:00:35,750 --> 00:00:42,680 So when you use a post method, imagine it as a way to send data in the bottom of the request that we 7 00:00:42,680 --> 00:00:43,370 are making. 8 00:00:44,150 --> 00:00:52,150 And usually it's a good practice that when we put any type of data there, we can also add in the content 9 00:00:52,160 --> 00:00:52,940 by header. 10 00:00:53,120 --> 00:00:59,120 So we know that we're working actually with forms and that our request is the appropriate type. 11 00:00:59,630 --> 00:01:05,480 So let me go now to the Web and show you our website that you can get more information about forums. 12 00:01:06,020 --> 00:01:14,780 So the site is called HTP Bindert Orac and it offers you a test server that returns certain data once 13 00:01:14,780 --> 00:01:15,790 we make a request. 14 00:01:16,400 --> 00:01:24,860 So if you scroll down here and we go to HTML form, you can see an actual form that corresponds to the 15 00:01:24,860 --> 00:01:25,690 post method. 16 00:01:26,990 --> 00:01:34,220 You can see that here we have customer type, customer name, telephone, email address, then it's 17 00:01:34,280 --> 00:01:34,560 site. 18 00:01:34,570 --> 00:01:36,410 So we have different bars here. 19 00:01:36,690 --> 00:01:43,250 They will have selectable buttons, multiple choice time field and delivery instructions. 20 00:01:43,430 --> 00:01:49,820 So it is a pretty good example of how you can post a forum into an e-mail format. 21 00:01:50,330 --> 00:01:56,630 So, for example, here I can type my email address and I can choose different things. 22 00:01:56,630 --> 00:02:02,350 I can choose I, for example, and deliver instructions and then we can submit the form. 23 00:02:02,960 --> 00:02:06,140 So let's do 11 or try. 24 00:02:07,670 --> 00:02:13,370 And you can see that after we submit the form, we're actually getting the message that is released 25 00:02:13,820 --> 00:02:14,660 from that forum. 26 00:02:14,660 --> 00:02:16,390 So we're getting the arguments. 27 00:02:16,430 --> 00:02:20,900 We'll get the header and the header is usually filled with the information that we just. 28 00:02:21,560 --> 00:02:26,520 So here we get the Jassam request to know the IP address in the euro as well. 29 00:02:26,930 --> 00:02:33,860 So this is the code that generates that form, basically, and this is how it will do what we inserted 30 00:02:33,860 --> 00:02:34,650 in this forum. 31 00:02:34,940 --> 00:02:41,390 So, for example, if we're to hear the content type, you can see that the content type is the application 32 00:02:41,420 --> 00:02:46,060 that will double double for euro, then call it. 33 00:02:46,120 --> 00:02:48,900 OK, so here we get a content type, basically. 34 00:02:50,030 --> 00:02:55,880 So let's go now to the idea in this construct, some request that is related to the forms. 35 00:02:56,550 --> 00:02:57,770 Let's write the terminal. 36 00:03:00,320 --> 00:03:02,780 And they may actually increase the size a bit. 37 00:03:03,920 --> 00:03:06,140 OK, so just bite them. 38 00:03:08,530 --> 00:03:18,460 So after we're in the python mode, let's write from your library and request. 39 00:03:20,180 --> 00:03:21,050 Import. 40 00:03:24,140 --> 00:03:25,040 A request. 41 00:03:27,570 --> 00:03:34,080 OK, so now we imported the packages, the package request, and now let's do Rikyu, which is going 42 00:03:34,080 --> 00:03:37,200 to be our object, is to request. 43 00:03:39,160 --> 00:03:43,990 And then inside the brackets, right, h h t p. 44 00:03:46,490 --> 00:03:58,130 And then let's say the name of the site that would just used so it would be called htp bin dot org slash 45 00:03:58,820 --> 00:04:03,170 post Colma data you of and data. 46 00:04:03,620 --> 00:04:10,740 OK, so actually you can see here that we don't define the data type, so data is undefined. 47 00:04:10,760 --> 00:04:13,670 So for that reason I will write data. 48 00:04:14,270 --> 00:04:16,090 You cause the URL. 49 00:04:18,930 --> 00:04:27,630 And quote, and then data there, rectory not. 50 00:04:30,240 --> 00:04:38,470 And cold, and then the brackets, I will simply write UTF eight. 51 00:04:39,450 --> 00:04:47,640 So let's actually hear, since we get on there to create the data dictionary module first and then we'll 52 00:04:47,640 --> 00:04:48,940 continue with the rest of the call. 53 00:04:49,320 --> 00:04:51,840 So what I will do, I will write the data. 54 00:04:55,300 --> 00:04:56,140 Dictionary. 55 00:04:58,970 --> 00:05:04,250 Equals break it and let's add some parameters to the dictionary. 56 00:05:04,970 --> 00:05:05,630 That's right. 57 00:05:07,680 --> 00:05:08,430 Customer. 58 00:05:10,900 --> 00:05:14,380 Now, right here, it's named Martin. 59 00:05:15,480 --> 00:05:18,850 Then let's try the telephone with the customer, so. 60 00:05:20,630 --> 00:05:25,150 Customers telephone, they will put it in parentheses. 61 00:05:25,250 --> 00:05:28,610 OK, and let's. 62 00:05:31,000 --> 00:05:31,420 Right. 63 00:05:31,450 --> 00:05:37,710 Thirty two thousand two hundred thirty three or thirty two, whatever, it actually doesn't matter. 64 00:05:38,140 --> 00:05:47,530 And let's find common size and let's also add parentheses here. 65 00:05:50,430 --> 00:05:52,410 So the sites will be lerche. 66 00:05:55,420 --> 00:05:57,280 And I think that's enough for now. 67 00:05:58,250 --> 00:06:05,860 OK, and actually not just here, guys, that they just missed one sign, so I would just add it. 68 00:06:08,380 --> 00:06:14,800 OK, so now we have the data dictionary and let us know from this data dictionary to create the data 69 00:06:14,800 --> 00:06:15,110 file. 70 00:06:15,130 --> 00:06:15,390 So. 71 00:06:15,400 --> 00:06:20,320 Right, the data equals you Arial library. 72 00:06:22,520 --> 00:06:26,720 Not who you are a parts. 73 00:06:28,450 --> 00:06:38,530 Or actually just pass that you are in cold and right data dictionary. 74 00:06:38,680 --> 00:06:40,460 That's it then. 75 00:06:41,170 --> 00:06:52,090 And code to use here, then code function and then code type will be you T.F. slash eight. 76 00:06:52,630 --> 00:06:53,090 OK. 77 00:06:55,110 --> 00:07:01,220 That's done, and if you get an error here, dismantling the course within that bureau library pass 78 00:07:01,240 --> 00:07:13,840 modules or just do you board your library pass and then run the command once again, that would fix 79 00:07:13,840 --> 00:07:14,320 that error. 80 00:07:15,210 --> 00:07:23,480 So let's us right from your library dot quest. 81 00:07:25,740 --> 00:07:28,830 Import request. 82 00:07:29,400 --> 00:07:35,070 OK, so import the request class and our list right to request equals. 83 00:07:38,200 --> 00:07:42,760 Request and then write the same thing, HTP. 84 00:07:45,240 --> 00:07:48,900 Slush h t t p. 85 00:07:50,830 --> 00:07:56,350 You've been dot org slash post. 86 00:07:58,670 --> 00:08:02,630 And then there you there. 87 00:08:03,050 --> 00:08:10,730 OK, so we're going to get the same issue, but I can see now why it is because here I rotate instead 88 00:08:10,730 --> 00:08:11,390 of Bayardo. 89 00:08:12,410 --> 00:08:13,130 So lame. 90 00:08:13,180 --> 00:08:13,850 Excuse that. 91 00:08:16,100 --> 00:08:19,280 And if I run the same request and I don't get any errors. 92 00:08:20,420 --> 00:08:33,560 OK, so let's add the here and I will write a request that at underscore the header and you can symptomatically 93 00:08:33,560 --> 00:08:48,620 the first and now in the here I will write content type comma in the application slash x. 94 00:08:50,880 --> 00:08:53,730 That's w w w 95 00:08:56,340 --> 00:08:59,610 forward slash, you are l. 96 00:09:02,360 --> 00:09:03,890 Learn, quote. 97 00:09:06,700 --> 00:09:07,720 Same column. 98 00:09:10,890 --> 00:09:16,230 Chavez said, because he utf dush aids. 99 00:09:16,980 --> 00:09:20,040 OK, and let's look better here. 100 00:09:20,190 --> 00:09:21,230 So that's accepted. 101 00:09:21,660 --> 00:09:32,340 And now we should do as a meeting of the request to the Jason Swoboda wants you, of course, eurorail 102 00:09:33,720 --> 00:09:39,510 open and you open the request. 103 00:09:39,670 --> 00:09:40,100 OK. 104 00:09:40,480 --> 00:09:45,180 OK, so right here you are to remember and talk to your opponent. 105 00:09:46,050 --> 00:09:54,300 OK, so if you get a senior right, Leura Labrador's DOT request that you're open and then you will 106 00:09:54,300 --> 00:10:08,280 be able to open actually the request, then let's write response direct, bring quotes Jassam to load 107 00:10:09,480 --> 00:10:11,280 and then the response. 108 00:10:11,610 --> 00:10:12,210 That's it. 109 00:10:14,100 --> 00:10:22,970 Of course, we need to first either Jason also report Jason and then this from the same comment and 110 00:10:22,980 --> 00:10:24,210 you can see that now intercepted separate. 111 00:10:24,210 --> 00:10:33,240 And if we do now print a response there, rectory, you can see that we are getting old arguments that 112 00:10:33,240 --> 00:10:35,580 were previously added. 113 00:10:35,580 --> 00:10:42,960 So the customers, the customers, Martin, on the telephone is three, two, two, three, two. 114 00:10:43,230 --> 00:10:44,540 And the size is large. 115 00:10:44,600 --> 00:10:49,600 OK, you can also see that the header has the same attributes that we added. 116 00:10:49,800 --> 00:10:51,390 So everything seems fine. 117 00:10:51,390 --> 00:11:00,120 You can see also like the address of the origin, so actually created and filled a form into this website 118 00:11:00,120 --> 00:11:02,140 just through the terminal using Python. 119 00:11:02,760 --> 00:11:10,200 So this is how guys, you can actually assess and the date forms on the web just from the terminal and 120 00:11:10,200 --> 00:11:11,080 using Python. 121 00:11:11,340 --> 00:11:12,770 Thank you very much for watching. 122 00:11:12,780 --> 00:11:16,770 And in the next lecture, we're going to continue talking about forms.