I'm asking you this question because there was an error when I was trying to download wget through Python

Asked 1 years ago, Updated 1 years ago, 70 views

This is a library

import wget
import math
import re 
from urllib import request

This is the address and file list to receive.

url = "ftp://ftp.hycom.org/datasets/GLBy0.08/expt_93.0/data/hindcasts/2021/"
html = request.urlopen(url)
html_contents = str(html.read().decode("cp949"))
url_list = re.findall(r"(hycom_GLBy0.08_930)(.+)(_ice.nc)", html_contents)

This is a code for continuously receiving as a repeating sentence

for url in url_list:
    url_full = "".join(url)
    file_name = url_full.split("/")[-1]
    print('\nDownloading ' + file_name)
    wget.download(url_full)

When executed, ValueError: unknown url type: 'hycom_GLBy0.08_930_2021010112_t000_ice.nc' It's leaving. The location of the error is

ValueError                                Traceback (most recent call last)
<ipython-input-23-c74ca47dac5e> in <module>
      3     file_name = url_full.split("/")[-1]
      4     print('\nDownloading ' + file_name)
----> 5     wget.download(url_full)

It's like this. Is there any mistake I made?

python3 download

2022-09-20 11:39

1 Answers

url_full has only file name url_full2 = 'url'+url_full[41:] and it works


2022-09-20 11:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.