In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "what are the advantages of Linux curl tools", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what are the advantages of Linux curl tools"?
Curl is a powerful http command line tool under Linux, and its function is very powerful.
1) Don't say a word, let's start here!
The code is as follows:
$curl https://www.yisu.com
After you enter, the html of www.yisu.com will be displayed on the screen.
2) well, is this the case if you want to save the read-over page?
The code is as follows:
$curl https://www.yisu.com > page.html
Sure, but don't bother!
Just use curl's built-in option, save the results of http, and use this option:-o
The code is as follows:
$curl-o page.html https://www.yisu.com
In this way, you can see a progress indication of the download page on the screen. When the progress reaches 100%, it will naturally be OK.
3) what?! Can't access it? It must be that your proxy is not set.
When using curl, you can use this option to specify the proxy server and its port used for http access:-x
The code is as follows:
$curl-x 123.45.67.89 page.html https://www.yisu.com 1080-o
4) it is annoying to visit some websites. He uses cookie to record session information.
Browsers like IE/NN can certainly easily handle cookie information, but what about our curl? .
Let's learn this option:-D after download: 001-zzh.JPG original: ~ nick/001.JPG-- > after download: 001-nick.JPG
In this way, we are not afraid of the duplicate name of the file, hehe
9) continue with downloading
We usually on the windows platform, tools like flashget can help us to download in parallel, but also can be disconnected and re-uploaded. Curl doesn't lose to anyone in these respects, hehe.
For example, when we download screen1.JPG and suddenly drop the line, we can start to continue the upload.
The code is as follows:
$curl-c-O https://cache.yisu.com/upload/information/20210312/303/123558.JPG
Of course, you should not fool me with a half-downloaded file from flashget. Half of the file downloaded by other software may not work.
Download in parts, and we can just use this option:-r
Give examples to illustrate
For example, we have a http://cgi2.tky.3web.ne.jp/~zzh/zhao1.MP3 to download (Miss Zhao's phone recitation: d) We can use this command:
The code is as follows:
$curl-r 0-10240-o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.MP3 &\
$curl-r 10241-20480-o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.MP3 &\
$curl-r 20481-40960-o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.MP3 &\
$curl-r 40961-o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.MP3
So you can download it in pieces. But you need to merge these broken files yourself. If you use UNIX or Apple, you can use cat zhao.part* > zhao.MP3. If you use Windows, use copy / b to solve the problem. Hehe.
What is mentioned above is the download of http protocol, in fact, ftp can also be used. Use it.
The code is as follows:
$curl-u name:passwd ftp://ip:port/path/file
Or something familiar to everyone.
The code is as follows:
$curl ftp://name:passwd@ip:port/path/file
10) after downloading, we should naturally talk about uploading. The uploaded option is-T.
For example, we send a file to ftp:
The code is as follows:
$curl-T localfile-u name:passwd ftp://upload_site:port/path/
Of course, uploading files to a http server can also be done, such as
The code is as follows:
$curl-T localfile http://cgi2.tky.3web.ne.jp/~zzh/abc.cgi
Note that at this point, the protocol used is HTTP's PUT method
Talking about PUT just now, hey, it naturally reminds the old server of other methos. Neither GET nor POST can be forgotten.
Http submits a form, which is more commonly used in POST schema and GET schema
GET mode does not use any option, you just need to write variables in url, such as:
The code is as follows:
$curl https://www.yisu.com/login.cgi?user=nickwolfe&password=12345
The option of POST mode is-d
such as,
The code is as follows:
$curl-d "user=nickwolfe&password=12345" https://www.yisu.com/login.cgi
It is equivalent to sending a login application to this site.
Whether to use GET mode or POST mode depends on the program setting of the opposite server.
One thing to note is that file uploads on files in POST mode, such as
The code is as follows:
For such an HTTP form, if we want to simulate it with curl, it should look like this syntax:
The code is as follows:
$curl-F upload=@localfile-F nick=go http://cgi2.tky.3web.ne.jp/~zzh/up_file.cgi
Having talked so much about it, in fact, curl still has a lot of skills and usage, such as using local certificates when using https.
The code is as follows:
$curl-E localcert.pem https://remote_server
For example, you can also use curl to look up the dictionary through the dict protocol.
The code is as follows:
$curl dict://dict.org/d:computer
At this point, I believe you have a deeper understanding of "what are the advantages of Linux curl tools?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.