Pinterest Question

Discussion in 'General Programming Chat' started by kegnum, May 3, 2012.

  1. kegnum

    kegnum Senior Member

    Joined:
    May 13, 2009
    Messages:
    1,027
    Likes Received:
    484
    Ok I have a list of image urls that I scraped from Google. Looking for a bot or an imacros script to grab the link from a list add it to pinterest, post a description and change the original image link to my site. Any ideas?
     
  2. weedsmoker

    weedsmoker Junior Member

    Joined:
    May 2, 2011
    Messages:
    191
    Likes Received:
    79
    Well i've quickly coded simple Python script for some pinning, didn't used it for a while but you get the basic idea.

    Code:
    import cookielib
    import re
    import urllib
    import urllib2
    
    URL_LOGIN = 'https://pinterest.com/login/?next=/'
    URL_LOGIN2 = 'https://pinterest.com/login/?next=%2Flogin%2F'
    URL_PIN_CREATE = 'http://pinterest.com/pin/create/button/'
    
    email = ''
    password = ''
    
    board_id = ''
    url = ''
    img_url = ''
    desc = ''
    
    # LOGIN
    cj = cookielib.MozillaCookieJar('cookies.txt')
    opener = urllib2.build_opener(
    ** *urllib2.HTTPRedirectHandler(),
    ** *urllib2.HTTPHandler(debuglevel=0),
    ** *urllib2.HTTPSHandler(debuglevel=0),
    ** *urllib2.HTTPCookieProcessor(cj)
    )
    opener.addheaders = [('User-agent', ('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)'))]
    response = opener.open(URL_LOGIN)
    matches = re.search("name='csrfmiddlewaretoken' value='(.*?)'", html)
    token = matches.group(1)
    form_data = urllib.urlencode({
    ** *'email':email,
    ** *'password':password,
    ** *'next':'/',
    ** *'csrfmiddlewaretoken':token
    })
    response = opener.open(URL_LOGIN2, form_data)
    
    # PIN CREATE
    form_data = urllib.urlencode({
    ** *'board':board_id,
    ** *'media_url':img_url,
    ** *'url':url,
    ** *'caption':desc,
    ** *'csrfmiddlewaretoken':token,
    ** *'form_url':'/pin/create/button/?'
    })
    response = opener.open(URL_PIN_CREATE, form_data)
    
     
    • Thanks Thanks x 1
  3. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,063
    Add me on skype, I might be able to help you out.