Curl yes Linux The next one is very powerful http Command line tools , It's very powerful .

1) Without saying , Let's start here !

$ curl

After the return , Of html It's on the screen     ~

2) Um. , To save the page you read , Is that what we want ?

$ curl > page.html

Certainly. , But it doesn't have to be that much trouble !

use curl The built-in option Just fine , keep for the future http Result , Use this option: -o

$ curl -o page.html

such , You can see a download page progress indicator on the screen . When we get there 100%, Naturally OK Slightly

3) What, what ?! Can't access ? It must be yours proxy No setting .

Use curl When , Use this option You can specify http Access the proxy The server and its port : -x

$ curl -x -o page.html

4) I hate visiting some websites , He USES cookie To record session Information .

image IE/NN A browser like this , Of course, it can be handled easily cookie Information , But our curl Well ?.....

Let's learn this option: -D <— This is a http Of response Inside cookie The information is stored in a special file

$ curl -x -o page.html -D cookie0001.txt

such , When the page is saved to page.html At the same time ,cookie Information is also stored in cookie0001.txt Inside the

5) that , The next time I visit , How to continue to use the last left cookie Information? ? Need to know , A lot of websites are monitoring you cookie Information , To see if you don't follow the rules to visit their website .

This time we use this option Let's take the last one cookie The information is appended to http request Go inside : -b

$ curl -x -o page1.html -D cookie0002.txt -b cookie0001.txt

such , We can simulate almost all of them IE operation , Go to the website !

6) Wait a little bit     ~ I seem to have forgotten something     ~

by the way ! It's browser information

Some annoying websites always ask us to use certain browsers to visit them , Sometimes it's more extreme , And use certain versions      NND, Where can I find these weird browsers for it !?

Fortunately curl It provides us with a useful option, We can freely specify our own browser information claimed by this visit : -A

$ curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x -o page.html -D cookie0001.txt

such , The server receives an access request , You'll think you're running on Windows 2000 Upper IE6.0, Hey, hey, hey , Actually, maybe you're using a Mac !

and "Mozilla/4.73 [en] (X11; U; Linux 2.2; 15 i686" You can tell the other person that you are a computer PC On the run Linux, It's using Netscape 4.73, Ha ha ha

7) Another common restriction method on the server side , It's inspection http Access to the referer. For example, you visit the home page first , Then visit the download page specified in it , This is my second visit to referer The address is the page address after the first successful visit . such , The server side only needs to find a certain access to the download page referer The address is not the address of the home page , We can conclude that it was a burglary company     ~

I hate it ~ I just want to steal company     ~!!

fortunately curl It gives us settings referer Of option: -e

$ curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x -e "" -o page.html -D cookie0001.txt

such , You can cheat each other's servers , You are from Click on a link , Ha ha ha

8) It's about finding something important missing !——- utilize curl Download the file

I said just now , Download the page to a file , have access to -o , It's the same with downloading files . such as ,

$ curl -o 1.jpg

Here's a new one option: -O uppercase O, So used :

$ curl -O

such , You can use the file name on the server , Automatically exists locally !

And a better one .

If screen1.JPG Besides screen2.JPG、screen3.JPG、....、screen10.JPG Need to download , It's hard for us to write a script To do this ?

Quit doing !

stay curl Inside , Just write like this :

$ curl -O[1-10].JPG

Ha ha ha , Terrible! ?! ~

9) Come again , Let's continue with download !

$ curl -O{zzh,nick}/[001-201].JPG

The resulting download , Namely









It's convenient enough ? Ha ha ha

Why ? Too soon to be happy .

because zzh/nick The file names under are 001,002...,201, The downloaded file has the same name , The latter has covered all the previous documents ~

No problem , We have more !

$ curl -o #2_#1.jpg{zzh,nick}/[001-201].JPG

— This is a ..... Download custom file name ? — Right , ha-ha !

such , Download the custom file name , That's how it became : original : ~zzh/001.JPG —-> After downloading : 001-zzh.JPG original : ~nick/001.JPG —-> After downloading : 001-nick.JPG

thus , I'm not afraid of duplicate names , ha-ha

Interesting explanation curl More articles about

  1. Ubuntu Command usage is explained in detail ——curl command

    brief introduction : cURL(CommandLine Uniform Resource Locator) Is a use of URL Syntax file transfer tool that works on the command line ,1997 First issued in . It supports file upload and download , So it's a comprehensive transmission worker ...

  2. Detailed explanation CURL Status code , The most complete code list

    curl It's a powerful command , Which we often use through curl Add the address and port number , Determine the target link status , The following is listed curl Status code returned . give an example : [root@k8s-master1 ~]# curl k8s-m ...

  3. sealed、new、virtual、abstract And override Interesting explanation

    1. sealed——“ die without descendants ” Sealed classes cannot be inherited . Sealed methods can override methods in base classes , But it itself cannot be further overridden in any derived class . When applied to Method or property ,sealed Modifiers must always be associated with override Use it together . ...

  4. 【 Design patterns 】GOF Interesting explanation of design pattern (23 Design patterns )

    Create pattern                    1.FACTORY— chase MM It's necessary to invite you to dinner , McDonald's chicken wings and KFC chicken wings are MM Favorite food , Although the taste is different , But no matter what you bring MM Go to McDonald's or KFC , Just tell the waiter ...

  5. Interesting explanation ceph rgw multisite data sync Mechanism

    multisite yes ceph rgw Object data remote disaster recovery backup is an effective solution , I hope to have a deep understanding of this technology , And applied to the production environment , However rgw This part of the code is obscure , I have tried to read many times , I still don't know what it means , Finally, with tears, biting ...

  6. linux curl Usage details

    linux ‍‍curl Usage details ‍‍curl The application of , First, you can use the command line tool directly , The other is to use libcurl Library to do the upper development . This article mainly summarizes the functions of command line tools http Related applications , In especial http Download ...

  7. Curl Slow request

    Background reason : The test environment found that there is a big difference between the intranet access latency and the extranet access latency of a connection , Intranet access is fast . Internet access is slow . So we use curl To diagnose the problem area ! The order is as follows : 1 curl -o /dev/null -s -w %{ ...

  8. Curl Tracking request latency problem

    Background reason : The test environment found that there is a big difference between the intranet access latency and the extranet access latency of a connection , Intranet access is fast . Internet access is slow . So we use curl To diagnose the problem area ! The order is as follows : curl -o /dev/null -s -w %{ti ...

  9. 《CURL Technical knowledge course 》 Series sharing column

    <CURL Technical knowledge course > It has been arranged into PDF file , Click to download directly to local search article PHP One of the collection related tutorials CUR ...

Random recommendation

  1. 【 database 】_ from 2000W Thinking caused by multiple housing data 、 practice ---- A reality for students at school 【 Rake yard 】, The classmates , Let's start a great experiment .

      ×   origin --- Hang out in the blog Garden The other day , At some point QQ The group saw a message “XXX The hotel opens rooms XXXBTXX thunderbolt BT download ”, At that time, I was browsing with a mind of ten lines at a glance , When the eyes pass , First reaction I think too much ~ Thought it was XX seeds ( You'll see ~ ...

  2. About checkbox Examples of select all and reverse select

    <script type="text/javascript"> $(function () { $("#checkAll").click(funct ...

  3. understand equal and gethashcode

    Supposed we have a class below public class TestHash { public int x; int y; public TestHash(int x, i ...

  4. Knights of the Round Table-POJ2942( Double connected components + Cross staining )

    Knights of the Round Table Description Being a knight is a very attractive career: searching for the ...

  5. Low key gorgeous ,Windows Server 2003 ... I'm tired of writing to XP, But I'm obsessed with vista/win7 Fancy children's shoes ( turn )

    Published on 2001 year 10 month 25 Japanese windows XP It's near now 8 year Time , Microsoft has never had an operating system like XP like that   Strong for so long , Marriage has both 7 Itch of the year , Besides, it uses 8 year XP The vast majority of classmate , but 07 Published in vista Seems to be ...

  6. 【 Reprint 】React What you need to know for beginners react.js Introduction learning Have a look at , Nothing special ...

  7. java Stream performance optimization 1- File replication

    Conventional I/O The speed is relatively slow , It will become the bottleneck of system performance , So in java1.4 And then there's NIO, It's a whole new stream : It has the following characteristics : 1. Provide... For all original types Buffer Cache support : 2. Use java.nio. ...

  8. Day040--HTML&amp;CSS

    Content review : Label classification : (1) In line labels span Small span labels i em a characteristic : (1) Show... In one line (2) Width and height cannot be set , If you don't set the width and height , The default is the width and height of the content (2) Block level label h1~h6 h1 The page is full of ...

  9. bootstrap Example

    <!DOCTYPE html> <html> <head> <title>Bootstrap 101 Template</title> &l ...

  10. spring in @Value(&quot;${key}&quot;) The value is output as is ${key} Analyze and solve

    problem : Recently found a project in , Pass in class @Value("${key}") Getting the variable value in the configuration file suddenly doesn't work , Direct output ${key}, The sample code is as follows : java Class : import org.s ...