Created
May 17, 2013 04:56
Revisions
-
iloahz renamed this gist
May 17, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
iloahz created this gist
May 17, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ 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!')