wget을 사용하여 sourceforge에서 파일을 다운로드하려고하지만 다운로드 버튼을 클릭 한 다음 자동 다운로드를 기다려야합니다. wget을 사용하여 이러한 유형의 파일을 어떻게 다운로드합니까?
이것을 다운로드하려고합니다 : http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.1/bitcoin-0.8.1-linux.tar.gz/download
그러나 해당 URL 링크에서 wget을 수행하면 파일이 브라우저를 통해 자동로드되므로 파일을 얻지 못합니다.
답변
나는 wget
당신과 sourceforge 사이에 어떤 버전 또는 OS와 프록시가 있는지 확실하지 않지만 wget
“/ download”를 제거하고 파일 확장자에 그대로두면 파일을 다운로드했습니다.
전체 세션에 포스트 또는 pastebin을 넘기고 싶지 않지만 전송이 시작되기 전에 302 그때 200 상태 코드를 얻었습니다. 시도하면 wget
어떻게 되나요?
Resolving downloads.sourceforge.net... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
[snipped for brevity]
HTTP request sent, awaiting response... 200 OK
Length: 13432789 (13M) [application/x-gzip]
Saving to: `download'
답변
curl
대신이 작업을 수행 하는 것이 좋습니다 wget
. 이 스위치를 사용하여 리디렉션을 따를 수 -L
, -J
및 -O
.
curl -O -J -L http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.1/bitcoin-0.8.1-linux.tar.gz/download
스위치 정의
-O/--remote-name
Write output to a local file named like the remote file we get.
(Only the file part of the remote file is used, the path is cut off.)
-L/--location
(HTTP/HTTPS) If the server reports that the requested page has moved
to a different location (indicated with a Location: header and a 3XX
response code), this option will make curl redo the request on the new
place. If used together with -i/--include or -I/--head, headers from
all requested pages will be shown. When authentication is used, curl only
sends its credentials to the initial host. If a redirect takes curl to a
different host, it won't be able to intercept the user+password.
See also --location-trusted on how to change this. You can limit the
amount of redirects to follow by using the --max-redirs option.
-J/--remote-header-name
(HTTP) This option tells the -O/--remote-name option to use the
server-specified Content-Disposition filename instead of extracting a
filename from the URL.
자세한 내용은 curl 매뉴얼 페이지 를 참조하십시오.
답변
에서 wget
당신은 사용할 수 있습니다 --content-disposition
사용 “내용 – 처리”헤더를 다운로드 한 파일의 이름이 있어야 할 무엇을 설명하는 몇 가지 파일 다운로드 CGI 프로그램에 유용합니다 옵션을 선택합니다.
예를 들면 다음과 같습니다.
wget --user-agent=Mozilla --content-disposition -E -c http://example.com/
보다 복잡한 솔루션 (예 : 인증 필요)의 경우 쿠키 파일 ( --load-cookies file
)을 사용하여 세션을 시뮬레이션하십시오.