Rss feed to pinterest

mfde69

Newbie
Joined
Nov 19, 2013
Messages
38
Reaction score
19
Hi, I am looking for a way to automatic pinning from any of IFFT channels to specific boards.

I am looking for something like delicious, where I bookmark to it then I have option to automatic posting to twitter. I need something similar for pinterest.

I found viraltag but its 29$ a month.

Thanks in advance

edit: I mean pinning from rss feed, but I thought of using ifft, rss feed -> pinterest. But IFFT doesn't support pinterest
 
Last edited:
Here is the setup I'd run if I were you. Note: It uses my private Pinterest class, and I'm not giving it out, so unless you hire somebody to mimic the functionality it isn't going to work for you. Also, the implementation below is very hacky. 2/10 would not suggest replicating some of my POC coding practices.

With this code (to you, pseudo code), you would structure your blog posts to have the same tag names as the boards you'd want them pinned to. From there it's pretty easy.

Code:
#Private for now. Sorry.
import Pinterest   
#pip install feedparser 
import feedparser

#Your RSS url - default on wordpress for RSS 2.0 is /path/to/blog/or/site/feed/ as reflected below
rss_url = "http://mysite.com/blog/feed/"

#Pinterest account information - Note: username can be username OR email
pinterest_username = ""
pinterest_password = ""

#Open and read token.txt which contains our little access token
def loadToken():
    return open("token.txt","r").read()

#Save the access token to token.txt
def saveToken(accessToken):
    f = open("token.txt","w")
    f.write(accessToken)
    f.close()

#Make sure we're in the main function because yolo
if __name__ == "__main__":

    #Instantiate a new Pinterest object
    pin = Pinterest()
    
    #Check to see if the access token is valid, otherwise login to the account
    token = loadToken()
    if pin.isValidToken(token):
        pin.setToken(token)
    else:
        if pin.login(pinterest_username, pinterest_password):
            #Save the token for later usage so we don't keep logging in/logging out and look suspicious
            saveToken(pin.accessToken)
        else:
            print "Could not login to account. Reason: %s" % pin.getLastError()
            exit()
    
    #Now that we're authenticated, we need to get our boards
    myBoards = pin.getMyBoards() #Store them in an array - it's also accessible as a public variable within the Pinterest object (pin.myBoards)
    
    #Fetch your RSS feed
    feed = feedparser.parse(rss_url)
    
    #Loop through posts
    for item in feed['entries']:
        post_url = item['link']
        description = item['description']    #probably a good idea to remove the htmlentities() stuff from here.
        content = item['content']    #Go ahead and parse out any images and put them in their own variable..we'll use "post_image" as the example.
        post_image = someImageParseFunction(content)
        
        #Now we loop through our boards and see if the board name matches up with any of our categories/tags for the post
        postBoard = None
        for board in myBoards:
            if board in item['category']:
                postBoard = board['id']
        if postBoard == None:
            print "No boards match the tags..."
            exit()
        else:
            if pin.pinUrl(postBoard, description, post_image, post_url):
                print "We successfully posted URL: %s to board %s" % post_url, postBoard
            else:
                print "There was an error posting the pin. Reason: %s" % pin.getLastError()

One last time to make sure it's abundantly clear. This will not work unless you have my Pinterest python class, which isn't available to the public (nor is it for sale). Sorry again.
 
Here is the setup I'd run if I were you. Note: It uses my private Pinterest class, and I'm not giving it out, so unless you hire somebody to mimic the functionality it isn't going to work for you. Also, the implementation below is very hacky. 2/10 would not suggest replicating some of my POC coding practices.

With this code (to you, pseudo code), you would structure your blog posts to have the same tag names as the boards you'd want them pinned to. From there it's pretty easy.

Code:
#Private for now. Sorry.
import Pinterest   
#pip install feedparser 
import feedparser

#Your RSS url - default on wordpress for RSS 2.0 is /path/to/blog/or/site/feed/ as reflected below
rss_url = "http://mysite.com/blog/feed/"

#Pinterest account information - Note: username can be username OR email
pinterest_username = ""
pinterest_password = ""

#Open and read token.txt which contains our little access token
def loadToken():
    return open("token.txt","r").read()

#Save the access token to token.txt
def saveToken(accessToken):
    f = open("token.txt","w")
    f.write(accessToken)
    f.close()

#Make sure we're in the main function because yolo
if __name__ == "__main__":

    #Instantiate a new Pinterest object
    pin = Pinterest()
    
    #Check to see if the access token is valid, otherwise login to the account
    token = loadToken()
    if pin.isValidToken(token):
        pin.setToken(token)
    else:
        if pin.login(pinterest_username, pinterest_password):
            #Save the token for later usage so we don't keep logging in/logging out and look suspicious
            saveToken(pin.accessToken)
        else:
            print "Could not login to account. Reason: %s" % pin.getLastError()
            exit()
    
    #Now that we're authenticated, we need to get our boards
    myBoards = pin.getMyBoards() #Store them in an array - it's also accessible as a public variable within the Pinterest object (pin.myBoards)
    
    #Fetch your RSS feed
    feed = feedparser.parse(rss_url)
    
    #Loop through posts
    for item in feed['entries']:
        post_url = item['link']
        description = item['description']    #probably a good idea to remove the htmlentities() stuff from here.
        content = item['content']    #Go ahead and parse out any images and put them in their own variable..we'll use "post_image" as the example.
        post_image = someImageParseFunction(content)
        
        #Now we loop through our boards and see if the board name matches up with any of our categories/tags for the post
        postBoard = None
        for board in myBoards:
            if board in item['category']:
                postBoard = board['id']
        if postBoard == None:
            print "No boards match the tags..."
            exit()
        else:
            if pin.pinUrl(postBoard, description, post_image, post_url):
                print "We successfully posted URL: %s to board %s" % post_url, postBoard
            else:
                print "There was an error posting the pin. Reason: %s" % pin.getLastError()

One last time to make sure it's abundantly clear. This will not work unless you have my Pinterest python class, which isn't available to the public (nor is it for sale). Sorry again.
Very nice code and share
 
Very nice code and share

Yeah, but completely useless.
OP has just confirmed "This will not work unless you have my Pinterest python class, which isn't available to the public (nor is it for sale). Sorry again. "
With that said OP has got something valuable which only he has got and it makes him very happy =)
 
try dlvr.it im 99% sure it has the pinterest auto poster your looking for. it has a paid and a free membership.
 
Yeah, but completely useless.
OP has just confirmed "This will not work unless you have my Pinterest python class, which isn't available to the public (nor is it for sale). Sorry again. "
With that said OP has got something valuable which only he has got and it makes him very happy =)

I wouldn't really call it valuable. It took me like 2 hours to code in it's entirety. Any semi-competent programmer could even hook Pinterest's web api and make it work with the snippet I pasted above (which was the point of my post to begin with).
 
I wouldn't really call it valuable. It took me like 2 hours to code in it's entirety. Any semi-competent programmer could even hook Pinterest's web api and make it work with the snippet I pasted above (which was the point of my post to begin with).

Pinterest has an API? I've been doing a LOT of scraping with my bot written in clojure. Where are the API docs?
 
Back
Top