Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import urllib.request
import csv
def create_articles(path):
temp = []
file = open(path, 'r')
for line in file:
arr = line.split(',')
#print(arr[0][-4:].lower())
if arr[0][-4:].lower() == '.pdf':
ext = 'pdf'
else:
ext = 'html'
temp.append(Article(arr[0], arr[1], ext))
return temp
def save_as_html(url, title, ext):
try:
urllib.request.urlretrieve(url, 'html/' + title + "." + ext)
except:
print("error happend on ", url)
def main():
articles = create_articles('instapaper-export.csv')
articles.pop(0)
print(len(articles))
for a in articles:
print('saving article number', articles.index(a), 'title:', a.title, 'and extention', a.ext)
save_as_html(a.url,str(articles.index(a)) + '-' + a.title, a.ext)
class Article:
def __init__(self, url, title, extention):
self.url = url
self.title = title
self.ext = extention
main()
@jakevossen5

This comment has been minimized.

Copy link
Owner Author

@jakevossen5 jakevossen5 commented Dec 14, 2018

This simply takes the csv you get as an export from your Instapaper account and saves it as a html page or a pdf page if the url ends in .pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment