0

I am trying to download a folder 'v30' within a directory from a website 'https://eogdata.mines.edu/wwwdata/viirs_products/vnf/' using urllib.request so that I can save the entire folder in my home directory.

I have tried to use the urllib library from python but not sure how to structure the codes to do the job

import urllib
import urllib.request
response = urllib2.urlopen('https://eogdata.mines.edu/wwwdata/viirs_products/vnf/v30/')
data = response.read()

homedir = 'C:\Users\Document'
file_ = open(filename, 'w')
file_.write(data)
file_.close()
Mikko
  • 29
  • 1
  • 7

1 Answers1

0

Install bs4 and requests, than you can use code like this:

import bs4 import requests

url = "http://bossa.pl/pub/metastock/ofe/sesjaofe/"
r = requests.get(url)
data = bs4.BeautifulSoup(r.text, "html.parser")
for l in data.find_all("a"):
    r = requests.get(url + l["href"])
    print(r.status_code)

Than you have to save the data of the request into your directory.