【问题标题】:Surf all pages of a web link with curl使用 curl 浏览 Web 链接的所有页面
【发布时间】:2014-04-09 09:32:49
【问题描述】:

我使用:

curl http://www.alibaba.com/corporations/Electrical_Plugs_%2526_Sockets/CID13--CN------------------50--OR------------BIZ1,BIZ2/30.html | iconv -f windows-1251 | grep -o -h 'data' >>out

过滤数据并保存到out,但是链接有67页,如何浏览该链接的所有页面并保存到out

非常感谢您的帮助!

【问题讨论】:

    标签: linux bash shell curl


    【解决方案1】:

    您可以使用Httrack下载整个网站,然后使用命令行工具在本地搜索特定内容

    http://www.nightbluefruit.com/blog/2010/03/copying-an-entire-website-with-httrack/

    或者,您可以在 wget 中使用 -r 递归开关

    http://www.gnu.org/software/wget/manual/html_node/Recursive-Retrieval-Options.html

    【讨论】:

    • 你能帮我配置httrack吗,我知道如何实现我的目标
    【解决方案2】:

    试试 for 循环

    #!/usr/bin/env bash
    
    url="http://www.alibaba.com/corporations/Electrical_Plugs_%2526_Sockets/CID13--CN------------------50--OR------------BIZ1,BIZ2"
    
    for i in {1..67}
    do
       curl $url/${i}.html | iconv -f windows-1251 >> out.$i
    done
    

    【讨论】:

      猜你喜欢
      • 2013-10-13
      • 2014-09-23
      • 2014-10-19
      • 2011-10-25
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多