Created
August 30, 2019 17:11
-
-
Save tomasonjo/79fc97f25639a0afcb0ee742a1ca2b1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.gutenberg.org/ebooks/95 Prisoner of Zelda | |
# Fetch the data | |
target_url = 'https://www.gutenberg.org/files/95/95-0.txt' | |
import urllib.request | |
data = urllib.request.urlopen(target_url) | |
raw_data = data.read().decode('utf8').strip() | |
# Preprocess text into chapters | |
import re | |
chapters = re.sub('[^A-z0-9 -]', ' ', raw_data).split('CHAPTER')[1:] | |
chapters[-1] = chapters[-1].split('End of the Project Gutenberg EBook')[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment