Last active
December 22, 2022 20:39
-
-
Save kylemoseby/098a0271331019239b81afce6276f20d to your computer and use it in GitHub Desktop.
Work with the Tumblr API using Python
This file contains hidden or 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
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