Skip to content

Instantly share code, notes, and snippets.

@iloahz
Created May 17, 2013 04:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iloahz/5597008 to your computer and use it in GitHub Desktop.
Save iloahz/5597008 to your computer and use it in GitHub Desktop.
v2ex auto coin
class V2exHandler(webapp2.RequestHandler):
def get(self, cmd):
return
if cmd == 'daily':
url = 'http://v2ex.com/signin'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31'),
('Referer', 'http://v2ex.com/signin')]
res = opener.open(url)
soup = BeautifulSoup(res)
soup = soup.findAll('form')[1]
once = soup.findAll('tr')[2].findAll('td')[1].find('input')['value']
form = {'u' : 'iloahz', 'p' : 'xxoohowkuaile', 'next' : '/', 'once' : once}
res = opener.open(url, urllib.urlencode(form))
url = 'http://v2ex.com/mission/daily'
res = opener.open(url)
soup = BeautifulSoup(res)
soup = soup.findAll('input')
url = soup[1]['onclick'].split("'")[1]
url = 'http://v2ex.com' + url.strip()
res = opener.open(url)
logging.info('Retrieved Successfully!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment