ageron / ageron/handson-ml2

Unable to Download the Spam Data, get a urlopen error

Open
#593 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

```python
DOWNLOAD_ROOT = "https://spamassassin.apache.org/old/publiccorpus/"
HAM_URL = DOWNLOAD_ROOT + '20030228_easy_ham.tar.bz2'
SPAM_URL = DOWNLOAD_ROOT + '20030228_spam.tar.bz2'
SPAM_PATH = os.path.join("datasets", "spam")

def fetch_spam(spam_url = SPAM_URL, ham_url = HAM_URL, spam_path = SPAM_PATH):
if not os.path.isdir(spam_path):
os.makedirs(spam_path)

for filename, url in (("ham.tar.bz2", ham_url), ("spam.tar.bz2", spam_url)):
path = os.path.join(spam_path, filename)
if not os.path.isfile(path):
urllib.request.urlretrieve(url, path)
tar_bz2_file = tarfile.open(path)
tar_bz2_file.extractall(path= spam_path)
tar_bz2_file.close()
```

When I run this function I get the error below:

```
URLError:
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.