curl 重定向_使用cURL跟随重定向

curl 重定向

I love playing around with cURL. There's something about loading websites via command line that makes me feel like some type of smug hacker, just like tweeting from command line does.

我喜欢玩cURL。 通过命令行加载网站有些让我感到像某种自鸣得意的黑客,就像从命令行发布推文一样。

I recently cURL'd the Google homepage and saw the following:

我最近在cURL'd Google主页上看到了以下内容:


curl google.com

#<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
#<TITLE>301 Moved</TITLE></HEAD><BODY>
#<H1>301 Moved</H1>
#The document has moved
#<A HREF="http://www.google.com/">here</A>.
#</BODY></HTML>


I found it weird that Google does the initial redirect but I still want to get the source of the Google homepage with cURL, as with any site that may do a redirect without you noticing. Luckily it's just a single flag:

我发现Google进行了初始重定向很奇怪,但是我仍然希望使用cURL来获取Google主页的来源,就像其他任何可能在没有引起您注意的情况下进行重定向的网站一样。 幸运的是,这只是一个标志:


curl -L google.com

#<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en">...


The -L flag instructs cURL to follow any redirect so that you reach the eventual endpoint. Those tiny redirects are just noise anyways, right?

-L标志指示cURL跟随任何重定向,以便您到达最终端点。 无论如何,那些微小的重定向只是噪音,对吗?

翻译自: https://davidwalsh.name/curl-follow-redirects

curl 重定向

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值