urlretrieve

urllib: specifying download path makes url invalid

urllib: specifying download path makes url invalid Question: I am trying to write a function that takes a url and a path and downloads a file to that path IF it’s a text file. import urllib import re import os mcBethURL = ‘https://ia802707.us.archive.org/1/items/macbeth02264gut/0ws3410.txt’ def download_file(url, path, local_filename): try: url_type = urllib.request.urlopen(url).info()[‘content-type’] if bool(re.search(‘t[e]*xt’, url_type)): local_filename …

Total answers: 1