S
S
SOTVM2018-06-13 15:40:07
linux
SOTVM, 2018-06-13 15:40:07

Download via proxy using wget?

I don't understand how to download a video through a proxy using wget ?
tried adding parameter (replace string)
wget --proxy "145.249.106.107:8118" -U "$ua" -c -i - 2>&1

function not working in script
filmDownload() {
    sed '/^#/d' "$playlist_path"/"$1".m3u |\
    wget -U "$ua" -c -i - 2>&1 |\
    sed -ur 's/.+\ +([0-9]+)%.*/\1/' |\
    zenity --progress --title "Загрузка файла..." --text "$1"
    }

I decided to "check it with my hands", pulled out a link from the .m3u file,
I open in vlc or smplayer through the specified proxy - it works,
vlc --http-proxy "145.249.106.107:8118" "http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4"

,
via wget - does not want to
$ wget -v --tries=3 -c --proxy  http://145.249.106.107:8118/ "http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4"
--2018-06-13 19:13:46--  http://145.249.106.107:8118/
Connecting to 145.249.106.107:8118... connected.
HTTP request sent, awaiting response... 400 Bad Request
2018-06-13 19:14:18 ERROR 400: Bad Request.

--2018-06-13 19:14:18--  http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4
Connecting to 50.7.127.154:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10 [text/html]
Saving to: ‘moroziki.morozy_480.mp4’

moroziki.morozy_480.mp4                 100%[=============================================================================>]      10  --.-KB/s    in 0s      

2018-06-13 19:14:18 (601 KB/s) - ‘moroziki.morozy_480.mp4’ saved [10/10]

FINISHED --2018-06-13 19:14:18--
Total wall clock time: 32s
Downloaded: 1 files, 10 in 0s (601 KB/s)

I thought the matter in the useragent changed, different, but apparently it's not about them,
because changing the useragent in the player, even to "blah blah blah" - the video shows.
and cookies are not used (without them, the player opens), which means binding only to the IP address i.e. to the proxy
I tried through curls - everything works
$ curl -v --proxy "145.249.106.107:8118"  -O  "http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4"*   Trying 145.249.106.107...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:15 --:--:--     0* Connected to 145.249.106.107 (145.249.106.107) port 8118 (#0)
> GET http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4 HTTP/1.1
> Host: 50.7.127.154
> User-Agent: curl/7.47.0
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
  0     0    0     0    0     0      0      0 --:--:--  0:00:16 --:--:--     0< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 13 Jun 2018 12:17:54 GMT
< Content-Type: video/mp4
< Content-Length: 44067403
< Last-Modified: Thu, 04 May 2017 12:29:50 GMT
< ETag: "590b1ebe-2a06a4b"
< Accept-Ranges: bytes
< Connection: close
* HTTP/1.1 proxy connection set close!
< Proxy-Connection: close
< 
{ [1448 bytes data]
100 42.0M  100 42.0M    0     0   447k      0  0:01:36  0:01:36 --:--:--  304k
* Closing connection 0
PS registered the proxy in the config ~/ .wgetrc
http_proxy = 145.249.106.107:8118
earned,
$ wget -v --tries=3 -c "http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4"--2018-06-13 19:53:13--  http://50.7.127.154/s/3a3b96c100ad2f10f7ea6acb70ad578f/sd_480v/moroziki.morozy_480.mp4
Connecting to 145.249.106.107:8118... connected.
Proxy request sent, awaiting response... 200 OK
Length: 44067403 (42M) [video/mp4]
Saving to: ‘moroziki.morozy_480.mp4’

moroziki.morozy_480.mp4                 100%[=============================================================================>]  42,03M   307KB/s    in 83s     

2018-06-13 19:54:41 (517 KB/s) - ‘moroziki.morozy_480.mp4’ saved [44067403/44067403]
BUT should I manage to steer proxies in the script itself, and not in the config?
what's wrong, what's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AVKor, 2018-06-13
@sotvm

http_proxy
in the config does not hint at anything?
This is first.
Secondly, the wget config can be specified explicitly via the --config. So you can even choose two options for launching: either register all the necessary options in the desired config file or specify it explicitly in the launch command.

M
mukhumaev, 2018-07-25
@mukhumaev

# Скачать файл через proxy:
http_proxy="http://33.22.44.44:8080" wget http://www.google.com/favicon.ico
  Тоже самое, но для HTTPS
https_proxy="http://33.22.44.44:8080" wget https://www.google.com/favicon.ico
 # Использовать proxy с авторизацией
http_proxy="http://33.22.44.44:8080" wget --proxy-user=user --proxy-password=password http://www.google.com/favicon.ico

Taken from here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question