V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
autoname
V2EX  ›  Java

爬虫怎么下载图片,拿到 Document 后怎么存图片

  •  
  •   autoname · Jul 10, 2020 · 2179 views
    This topic created in 2128 days ago, the information mentioned may be changed or developed.

    爬虫怎么下载图片,jsoup 拿到 Document 后怎么存图片

    是解析 Document 里面的 src 路径 再请求一次吗,

    请求一次 Document 不能保存里面的图片吗

    要是几十张图片, 莫不是要再请求几十次,才能下载下来啊

    有没有办法拿到 Document 里面的图片 src 直接可以下载的

    只 get 一次

    Supplement 1  ·  Jul 11, 2020
    6 replies    2020-07-11 01:23:23 +08:00
    M003
        1
    M003  
       Jul 10, 2020
    这你不是想多了么,浏览器访问,还都是根据 src 再次请求图片资源的.
    luckyc
        2
    luckyc  
       Jul 10, 2020
    想什么呢, 你以为浏览器打开一个页面就请求了一次吗?
    js/css/img 还不都是根据内容再去加载的?
    autoname
        3
    autoname  
    OP
       Jul 10, 2020
    @l4ever
    @M003
    太残忍了,一下就打醒我了
    autoname
        4
    autoname  
    OP
       Jul 10, 2020
    其实我是想,爬 dz 的验证码

    这是图片直链,misc.php?mod=seccode&update=49424&idhash=cS0

    但是不能这么直接访问是没效果的,虽然带上 cookie 啥的,验证码也会变,

    但是回帖校验的时候还是提示错误, 得先请求一次这个地址,
    misc.php?mod=seccode&action=update&idhash=cS0&0.0423275371233075&modid=undefined
    然后去校验,才是正确的

    问题是,这里面只能发送一次 get 请求, 到这个地址去更新验证
    misc.php?mod=seccode&action=update&idhash=cS0&0.0423275371233075&modid=undefined

    但 这个页面又不是验证码直链,得不到直链。就没办法解码了

    不知道怎么弄了,求 dz 爬虫大佬指点
    Wait845
        5
    Wait845  
       Jul 11, 2020
    dz 是什么敏感词🐎
    autoname
        6
    autoname  
    OP
       Jul 11, 2020
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 20:34 · PVG 04:34 · LAX 13:34 · JFK 16:34
    ♥ Do have faith in what you're doing.