Linux: cURL抓取页面, cURL支持页面跳转抓取, Follow Redirects with cURL

最近抓取谷歌首页面:

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>

内容大概就是,页面发生了跳转,解决方法如下:

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.

 

 

本文:Linux: cURL抓取页面, cURL支持页面跳转抓取, Follow Redirects with cURL

One Comment

Leave a Reply