Skip to content

Instantly share code, notes, and snippets.

Last active December 14, 2018 02:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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(',')
if arr[0][-4:].lower() == '.pdf':
ext = 'pdf'
ext = 'html'
temp.append(Article(arr[0], arr[1], ext))
return temp
def save_as_html(url, title, ext):
urllib.request.urlretrieve(url, 'html/' + title + "." + ext)
print("error happend on ", url)
def main():
articles = create_articles('instapaper-export.csv')
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
Copy link

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