Skip to content

Instantly share code, notes, and snippets.

@jakevossen5
Last active December 14, 2018 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakevossen5/5d3f6cc7c8a74dc3031640949050a96f to your computer and use it in GitHub Desktop.
Save jakevossen5/5d3f6cc7c8a74dc3031640949050a96f to your computer and use it in GitHub Desktop.
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
Copy link
Author

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