- [Instructor] Hello again
and welcome to the last video of section five.
Posting to a web page and reading their response.
In the previous video we learned how to track
changes to a website.
In this video, we'll see how to post
to a web page and read the response.
Post and get are two types of requests
in http to send information to
or retrieve information from a website.
In a get request, we send parameters,
name value pairs, through the web page url itself.
In the case of post, it won't be attached with the url.
Post is used when a form needs to be submitted.
For example, a username, the password to be submitted.
And the log in page to be retrieved.
Posting to pages is used frequently while writing
scripts based on web page retrievals.
Let's see how to work with post.
Automating the http get and post request
by sending the post data and retrieving the output
is a very important task that we practice
while writing shell scripts that pass data from websites.
For this video, we'll use a test website.
Book.sarahlatchman.com/lsc/mlogs
which is used to submit the current user information,
such as the host name and username.
In the homepage of the website,
there are two fields.
Host name and user and a submit button.
When the user enters a host name,
a username and clicks on the submit button,
the details will be stored in the website.
This process can be automated by using a single
line of cURL or w get command by automating
the post request.
Let's see how to do this by using cURL or w get.
Post and read the html response.
My real website is in cURL as follows.
cURL prints the response page.
Minus D is the argument used for posting.
The string argument for minus D
is similar to the get request semantics.
Var equals value pairs after we delimited
by ampersand.
You compose the data using W get
by using the minus minus post minus data string.
For example.
Use the same format as cURL for the name value pairs.
The string to post arguments,
for example, two minus D, or minus minus post minus data
should always be given in quotes.
If quotes are not used,
ampersand is interrupted by the shell
to indicate that this could be a background process.
If you look at the website source,
use the view source option from the web browser,
you'll see an html form defined
similar to a following code here.
When the user enters the details
and clicks on the submit button,
the host and user inputs are sent
to submit.php as a post request.
And the response page is returned on the browser.
Awesome.
In this video,
we've seen how to post to a web page
and read the response.
This video concludes the fifth section of this course.
We first learned about downloading from a web page
and then we moved on to downloading
a web page as plain text.
After that we've seen about a primer on cURL.
Then we moved on to parsing data from a website.
Also, we've seen about image crawler and downloader.
Then we learned how to generate a web photo album.
We then learned about creating a "define" utility
by using the web backend.
Also, we've learned how to find broken links in a website.
Then we've seen about tracking changes to a website.
Finally, we've seen about posting to a web page
and reading a response.
All the following videos in all of the next sections
we will walk through different recipes
for creating and maintaining files and folder archives.
Compression formats and encrypting techniques with shell.
So the next section,
we'll discuss about the backup plan.