Search for untagged messages on Tumblr (requested Python-3.3 coding help)

I am extremely new to coding in general; I delved into this project to help my friend tag her fifteen thousand and a few extra posts on Tumblr. We are finally done, but she wants to be sure that we haven’t missed anything ... So, I browsed the Internet, trying to find a solution for encoding. I came across a script found here that supposedly does exactly what we need - so I downloaded Python and ... It doesn't work.

More specifically, when I click on the script, the black box appears for about a second and a half, and then disappears. I could not take a screenshot to find out what it says, but I believe there is a syntax error. At first I tried with Python 2.4; it didn't seem to find the Json module the creator uses, so I switched to Python 3.3, the latest version for Windows, and that is where the syntax errors happen.

#!/usr/bin/python

import urllib2
import json

hostname = "(Redacted for Privacy)"
api_key = "(Redacted for Privacy)"

url = "http://api.tumblr.com/v2/blog/" + hostname + "/posts?api_key=" + api_key

def api_response(url):
req = urllib2.urlopen(url)
return json.loads(req.read())

jsonresponse = api_response(url)
post_count = jsonresponse["response"]["total_posts"]
increments = (post_count + 20) / 20

for i in range(0, increments):

  jsonresponse = api_response(url + "&offset=" + str((i * 20)))
  posts = jsonresponse["response"]["posts"]

for i in range(0, len(posts)):
 if not posts[i]["tags"]:
  print posts[i]["post_url"]

print("All finished!")

, : , , Untagged Posts on Tumblr, ? ( Tumblr, Python), - script Tumblr? Tumblr, , .

, , Python C:\Python33.

.

+3
2

script, ,

, Python script , , do 0 "Learn Python The Hard Way" .


" Tumblr" Python 2 script ( import urllib2 . urllib2 urllib.request Python 3). script Python 3:

#!/usr/bin/env python3
"""Find untagged tumblr posts.

Python 3 port of the script from
  http://www.alexwlchan.net/2013/08/untagged-tumblr-posts/
"""
import json
from itertools import count
from urllib.request import urlopen

hostname, api_key = "(Redacted for Privacy)", "(Redacted for Privacy)"
url = "https://api.tumblr.com/v2/blog/{blog}/posts?api_key={key}".format(
    blog=hostname, key=api_key)

for offset in count(step=20):
    r = json.loads(urlopen(url + "&offset=" + str(offset)).read().decode())
    posts = r["response"]["posts"]
    if not posts: # no more posts
        break
    for post in posts:
        if not post["tags"]: # no tags
            print(post["post_url"])

, Python Tumblr API v2 Client ( Python 2):

#!/usr/bin/env python
from itertools import count
import pytumblr # $ pip install pytumblr

hostname, api_key = "(Redacted for Privacy)", "(Redacted for Privacy)"
client = pytumblr.TumblrRestClient(api_key, host="https://api.tumblr.com")
for offset in count(step=20):
    posts = client.posts(hostname, offset=offset)["posts"]
    if not posts: # no more posts
        break
    for post in posts:
        if not post["tags"]: # no tags
            print(post["post_url"])
+2

All Articles