Created
May 17, 2013 04:56
-
-
Save iloahz/5597008 to your computer and use it in GitHub Desktop.
v2ex auto coin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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