Skip to content

Instantly share code, notes, and snippets.

@kylemoseby
Last active December 22, 2022 20:39
Show Gist options
  • Save kylemoseby/098a0271331019239b81afce6276f20d to your computer and use it in GitHub Desktop.
Save kylemoseby/098a0271331019239b81afce6276f20d to your computer and use it in GitHub Desktop.
Work with the Tumblr API using Python
import csv
import pytumblr
class tumblrAccount():
# Authenticate via OAuth
client = pytumblr.TumblrRestClient(
# INPUT API INFO HERE
)
post_offset = 0
def __init__(self):
self.createCSVfile()
def createCSVfile(self):
blog_name = "tumblr_blog"
for blog in self.client.info().get("user").get("blogs"):
if blog.get("primary"):
blog_name = blog.get("name")
tumblr_csv = open(blog_name + "-tumblr-backup.csv", "wb")
self.csv_posts = csv.writer(tumblr_csv, quotechar='"', quoting=csv.QUOTE_ALL)
print "CSV written to disk"
def callPosts(self):
response = self.client.posts('kylemoseby.tumblr.com', limit=50, offset=0)
meta = response.get("blogrom")
return response.get("posts")
__tumblr__ = tumblrAccount()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment