Created
June 29, 2012 15:23
-
-
Save sash13/3018582 to your computer and use it in GitHub Desktop.
pythonS60 G:plus
This file contains hidden or 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
| #coding:utf-8 | |
| from appuifw import * | |
| import e32 | |
| import os | |
| import urllib, urllib2, cookielib, time | |
| if e32.in_emulator(): | |
| imagedir=u'c:\\images' | |
| else: | |
| imagedir=u'e:\\images' | |
| data_path=os.getcwd()[0]+u':\\System\\data\\Plus\\' | |
| cook = 'cook.dat' | |
| files=map(unicode,os.listdir(imagedir)) | |
| class Main: | |
| def __init__(self): | |
| app.screen='normal' | |
| self.settings ={} | |
| self.cj = cookielib.LWPCookieJar() | |
| try: | |
| self.settings=eval(open(data_path+'set.dat').read()) | |
| except: | |
| self.settings['email'] = u'' | |
| self.settings['pass'] = u'' | |
| self.fields=[ | |
| (u"Email",'text',self.settings['email']), | |
| (u"Pass",'text',self.settings['pass']), | |
| (u"Text",'text',u''), | |
| (u"Image", 'combo', (files, 0)) | |
| ] | |
| self.form=Form(self.fields,flags=FFormEditModeOnly) | |
| self.form.save_hook=self.save | |
| self.form.menu=[(u'+Post',self.post_to_plus)] | |
| self.form.execute() | |
| def input_parse(self, base): | |
| query = 'input ' | |
| input_parts = {} | |
| sta=0 | |
| while sta !=-1: | |
| sta=base[1:].find(query) | |
| if sta == -1: | |
| break | |
| sta_len = sta+len(query) | |
| end = base[sta_len:].find('>')+sta_len | |
| stroka = base[sta_len:end] | |
| name = stroka.split('name="')[1].split('"')[0] | |
| try: | |
| value = stroka.split('value="')[1].split('"')[0] | |
| except: | |
| value = u'' | |
| input_parts[name]=value | |
| base=base[end:] | |
| return input_parts | |
| def login_func(self, email, passwd): | |
| content, url = self.url_get('https://m.google.com/app/plus/') | |
| input_list = self.input_parse(content) | |
| print url, ' ', input_list | |
| data = urllib.urlencode( | |
| {'continue': input_list['continue'], 'followup': input_list['followup'], 'service': input_list['service'], | |
| 'dsh': input_list['dsh'], 'btmpl':input_list['btmpl'], 'GALX':input_list['GALX'], 'timeStmp':input_list['timeStmp'], | |
| 'secTok': input_list['secTok'], 'Email':email_my, 'Passwd': pass_my, 'signIn':input_list['signIn']}) | |
| self.opener.add_header = ('Referer', 'https://m.google.com/app/plus/' | |
| content, url = self.url_get('https://accounts.google.com/ServiceLoginAuth',data) | |
| self.cj.save(data_path+cook,ignore_expires=True, ignore_discard=True) | |
| self.opener.add_header = ('Referer', url) | |
| return url | |
| def create_opener(self): | |
| return urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
| def url_get(self, url,data=None): | |
| time.sleep(1) | |
| try: | |
| res = self.opener.open(url, data) | |
| except HTTPError, e: | |
| print e.headers | |
| print 'Cookies', list(cookieprocessor.cookiejar) | |
| return res.read(), res.geturl() | |
| def save(self,arg=None): | |
| print arg[0][2] | |
| print arg[1][2] | |
| self.settings['email']=arg[0][2] | |
| self.settings['pass']=arg[1][2] | |
| open(data_path+'set.dat','w').write(repr(self.settings)) | |
| self.opener = self.create_opener() | |
| url = self.login_func(arg[0][2], arg[1][2]) | |
| pref=url.split('?')[0] | |
| return True | |
| a=Main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment