AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / unix / Perguntas / 738620
Accepted
decipher
decipher
Asked: 2023-03-04 17:27:48 +0800 CST2023-03-04 17:27:48 +0800 CST 2023-03-04 17:27:48 +0800 CST

Baixe o arquivo seguindo muitos redirecionamentos

  • 772

Eu preciso baixar um apk desta página da web,

https://www.apkmirror.com/apk/google-inc/youtube-music/youtube-music-5-46-52-release/youtube-music-5-46-52-2-android-apk-download/

Isso redireciona para outra página e, em seguida, o download é iniciado. Eu quero wgetsegui-lo e baixar aquele arquivo específico. Também tentei soluções mais antigas no estouro de pilha, como

curl -L -J -O 

e

wget --content-disposition and max redirect = 20

Todos tentaram, nada baixa esse arquivo

Eu quero fazer isso com wgetapenas.

curl
  • 1 1 respostas
  • 44 Views

1 respostas

  • Voted
  1. Best Answer
    Gilles Quénot
    2023-03-04T17:44:33+08:002023-03-04T17:44:33+08:00

    Assim, até onde você adicionou a tag curl :

    Parece que o servidor se recusa a servir o arquivo se você não tiver um navegador real. Na medida em que não é muito difícil de contornar, esta é uma maneira de conseguir baixar mais como um navegador faz:

    curl -A Mozilla/5.0 -k -L -b ~/.cache/mycurl.cookiejar \
    -c ~/.cache/mycurl.cookiejar -s \
    'https://www.apkmirror.com/wp-content/themes/APKMirror/download.php?id=4494773&key=9f9ed89d76339d3a888e036627a9f1c80fd64c35&forcebaseapk=true' \
    -C - > 'com.google.android.apps.youtube.music_5.46.52-54652240_minAPI21(arm64-v8a)(nodpi)_apkmirror.com.apk'
    

    Explicações

    • -A: imita o user-agent defirefox
    • -b -c: lidarcookies
    • -L: seguir redirecionamentos
    • -s: modo silencioso
    • -C: continuar se o download for interrompido
    • -k: modo inseguro (aceita todos os certificados, mesmo autoassinado)

    Este é um trecho obrigatório no baú de ferramentas

    Este é o meu próprio invólucro do Curl:

    #!/bin/bash
    
    curl -A "Mozilla/5.0" -k -L -b ~/.cache/mycurl.cookiejar \
        -c ~/.cache/mycurl.cookiejar -s "$@" -C - && exit 0
    
    retval=$?
    
    case $retval in
        1)  echo >&2 "Unsupported protocol. This build of curl has no support for this protocol." ;;
        2)  echo >&2 "Failed to initialize." ;;
        3)  echo >&2 "URL malformed. The syntax was not correct." ;;
        4)  echo >&2 "A feature or option that was needed to perform the desired request was not enabled or was explicitly disabled at build-time. \
                To make curl able to do this, you  probably  need  another build of libcurl!" ;;
        5)  echo >&2 "Couldn't resolve proxy. The given proxy host could not be resolved." ;;
        6)  echo >&2 "Couldn't resolve host. The given remote host was not resolved." ;;
        7)  echo >&2 "Failed to connect to host." ;;
        8)  echo >&2 "FTP weird server reply. The server sent data curl couldn't parse." ;;
        9)  echo >&2 "FTP  access  denied.  The  server denied login or denied access to the particular resource or directory you wanted to reach. \
            Most often you tried to change to a directory that doesn't exist on the server." ;;
        11) echo >&2 "FTP weird PASS reply. Curl couldn't parse the reply sent to the PASS request." ;;
        13) echo >&2 "FTP weird PASV reply, Curl couldn't parse the reply sent to the PASV request." ;;
        14) echo >&2 "FTP weird 227 format. Curl couldn't parse the 227-line the server sent." ;;
        15) echo >&2 "FTP can't get host. Couldn't resolve the host IP we got in the 227-line." ;;
        17) echo >&2 "FTP couldn't set binary. Couldn't change transfer method to binary." ;;
        18) echo >&2 "Partial file. Only a part of the file was transferred." ;;
        19) echo >&2 "FTP couldn't download/access the given file, the RETR (or similar) command failed." ;;
        21) echo >&2 "FTP quote error. A quote command returned error from the server." ;;
        22) echo >&2 "HTTP page not retrieved. The requested url was not found or returned another error with the HTTP error code being 400 or above. This return code only appears if -f, --fail is used." ;;
        23) echo >&2 "Write error. Curl couldn't write data to a local filesystem or similar." ;;
        25) echo >&2 "FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading." ;;
        26) echo >&2 "Read error. Various reading problems." ;;
        27) echo >&2 "Out of memory. A memory allocation request failed." ;;
        28) echo >&2 "Operation timeout. The specified time-out period was reached according to the conditions." ;;
        30) echo >&2 "FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT command, try doing a transfer using PASV instead!" ;;
        31) echo >&2 "FTP couldn't use REST. The REST command failed. This command is used for resumed FTP transfers." ;;
        33) echo >&2 "HTTP range error. The range \"command\" didn't work." ;;
        34) echo >&2 "HTTP post error. Internal post-request generation error." ;;
        35) echo >&2 "SSL connect error. The SSL handshaking failed." ;;
        36) echo >&2 "FTP bad download resume. Couldn't continue an earlier aborted download." ;;
        37) echo >&2 "FILE couldn't read file. Failed to open the file. Permissions?" ;;
        38) echo >&2 "LDAP cannot bind. LDAP bind operation failed." ;;
        39) echo >&2 "LDAP search failed." ;;
        41) echo >&2 "Function not found. A required LDAP function was not found." ;;
        42) echo >&2 "Aborted by callback. An application told curl to abort the operation." ;;
        43) echo >&2 "Internal error. A function was called with a bad parameter." ;;
        45) echo >&2 "Interface error. A specified outgoing interface could not be used." ;;
        47) echo >&2 "Too many redirects. When following redirects, curl hit the maximum amount." ;;
        48) echo >&2 "Unknown option specified to libcurl. This indicates that you passed a weird option to curl that was passed on to libcurl and rejected. Read up in the manual!" ;;
        49) echo >&2 "Malformed telnet option." ;;
        51) echo >&2 "The peer's SSL certificate or SSH MD5 fingerprint was not OK." ;;
        52) echo >&2 "The server didn't reply anything, which here is considered an error." ;;
        53) echo >&2 "SSL crypto engine not found." ;;
        54) echo >&2 "Cannot set SSL crypto engine as default." ;;
        55) echo >&2 "Failed sending network data." ;;
        56) echo >&2 "Failure in receiving network data." ;;
        58) echo >&2 "Problem with the local certificate." ;;
        59) echo >&2 "Couldn't use specified SSL cipher." ;;
        60) echo >&2 "Peer certificate cannot be authenticated with known CA certificates." ;;
        61) echo >&2 "Unrecognized transfer encoding." ;;
        62) echo >&2 "Invalid LDAP URL." ;;
        63) echo >&2 "Maximum file size exceeded." ;;
        64) echo >&2 "Requested FTP SSL level failed." ;;
        65) echo >&2 "Sending the data requires a rewind that failed." ;;
        66) echo >&2 "Failed to initialise SSL Engine." ;;
        67) echo >&2 "The user name, password, or similar was not accepted and curl failed to log in." ;;
        68) echo >&2 "File not found on TFTP server." ;;
        69) echo >&2 "Permission problem on TFTP server." ;;
        70) echo >&2 "Out of disk space on TFTP server." ;;
        71) echo >&2 "Illegal TFTP operation." ;;
        72) echo >&2 "Unknown TFTP transfer ID." ;;
        73) echo >&2 "File already exists (TFTP)." ;;
        74) echo >&2 "No such user (TFTP)." ;;
        75) echo >&2 "Character conversion failed." ;;
        76) echo >&2 "Character conversion functions required." ;;
        77) echo >&2 "Problem with reading the SSL CA cert (path? access rights?)." ;;
        78) echo >&2 "The resource referenced in the URL does not exist." ;;
        79) echo >&2 "An unspecified error occurred during the SSH session." ;;
        80) echo >&2 "Failed to shut down the SSL connection." ;;
        82) echo >&2 "Could not load CRL file, missing or wrong format (added in 7.19.0)." ;;
        83) echo >&2 "Issuer check failed (added in 7.19.0)." ;;
        84) echo >&2 "The FTP PRET command failed" ;;
        85) echo >&2 "RTSP: mismatch of CSeq numbers" ;;
        86) echo >&2 "RTSP: mismatch of Session Identifiers" ;;
        87) echo >&2 "unable to parse FTP file list" ;;
        88) echo >&2 "FTP chunk callback reported error" ;;
         *) echo >&2 "Undocumented error" ;; 
    esac
    
    exit $retval
    

    Uso

    Curl https://unexistantdomain.io
    Couldn't resolve host. The given remote host was not resolved.
    

    ou

    Curl https://ifconfig.me/all.json | jq -r '.ip_addr'
    1.1.1.1
    
    • 2

relate perguntas

  • Não baixe o arquivo com curl se o arquivo já existir localmente

  • Como enrolar e descompactar para um determinado diretório? [duplicado]

  • Verificando um redirecionamento de URL do terminal

  • Obtendo o endereço URL do arquivo e verificando o código HTTP

  • Como baixar um arquivo no terminal cujo link redireciona e parece funcionar apenas na GUI?

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve