Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2012 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2169730 to your computer and use it in GitHub Desktop.
Save anonymous/2169730 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from BeautifulSoup import BeautifulSoup
import time
import urllib
import urllib2
HEADERS = {
'Accept': '*/*',
'Accept-Charset': 'utf-8',
'Accept-Language': 'en-US,en;q=0.8',
'Host': 'dcurt.is',
'Origin': 'http://dcurt.is',
'Referer': 'http://dcurt.is/',
'User-Agent': 'Mozilla/5.0',
}
def get_id(path):
ident = {}
req = urllib2.Request('http://dcurt.is/' + path, headers=HEADERS)
resp = urllib2.urlopen(req)
meta = resp.info()
ident['cookie'] = meta['Set-Cookie'].split(';', 1)[0]
html = resp.read()
soup = BeautifulSoup(html)
ident['extid'] = soup.find("span", "extid").text
ident['token'] = soup.find("meta", {'name': "csrf-token"})['content']
return ident
def kudos(ident):
body = urllib.urlencode({'external_id': ident['extid']})
headers = HEADERS.copy()
headers.update({
'Cookie': ident['cookie'],
'X-CSRF-Token': ident['token'],
'X-Requested-With': 'XMLHttpRequest',
})
req = urllib2.Request('http://dcurt.is/kudos', body, headers)
urllib2.urlopen(req)
while True:
ident = get_id('codename-svbtle')
kudos(ident)
print 'Kudos!'
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment