亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? libgmail.py

?? 一個用Python的gmail功能庫
?? PY
?? 第 1 頁 / 共 4 頁
字號:
#!/usr/bin/env python## libgmail -- Gmail access via Python### To get the version number of the available libgmail version.## Reminder: add date before next release. This attribute is also## used in the setup script.Version = '0.1.11' # (August 2008)# Original author: follower@rancidbacon.com# Maintainers: Waseem (wdaher@mit.edu) and Stas Z (stas@linux.isbeter.nl)## License: GPL 2.0## NOTE:#   You should ensure you are permitted to use this script before using it#   to access Google's Gmail servers.### Gmail Implementation Notes# ==========================## * Folders contain message threads, not individual messages. At present I#   do not know any way to list all messages without processing thread list.#LG_DEBUG=0from lgconstants import *import os,pprintimport reimport urllibimport urllib2import mimetypesimport typesimport mechanize as ClientCookiefrom cPickle import load, dumpfrom email.MIMEBase import MIMEBasefrom email.MIMEText import MIMETextfrom email.MIMEMultipart import MIMEMultipartGMAIL_URL_LOGIN = "https://www.google.com/accounts/ServiceLoginBoxAuth"GMAIL_URL_GMAIL = "https://mail.google.com/mail/?ui=1&"#  Set to any value to use proxy.PROXY_URL = None  # e.g. libgmail.PROXY_URL = 'myproxy.org:3128'# TODO: Get these on the fly?STANDARD_FOLDERS = [U_INBOX_SEARCH, U_STARRED_SEARCH,                    U_ALL_SEARCH, U_DRAFTS_SEARCH,                    U_SENT_SEARCH, U_SPAM_SEARCH]# Constants with names not from the Gmail Javascript:# TODO: Move to `lgconstants.py`?U_SAVEDRAFT_VIEW = "sd"D_DRAFTINFO = "di"# NOTE: All other DI_* field offsets seem to match the MI_* field offsetsDI_BODY = 19versionWarned = False # If the Javascript version is different have we                      # warned about it?RE_SPLIT_PAGE_CONTENT = re.compile("D\((.*?)\);", re.DOTALL)class GmailError(Exception):    '''    Exception thrown upon gmail-specific failures, in particular a    failure to log in and a failure to parse responses.    '''    passclass GmailSendError(Exception):    '''    Exception to throw if we are unable to send a message    '''    passdef _parsePage(pageContent):    """    Parse the supplied HTML page and extract useful information from    the embedded Javascript.        """    lines = pageContent.splitlines()    data = '\n'.join([x for x in lines if x and x[0] in ['D', ')', ',', ']']])    #data = data.replace(',,',',').replace(',,',',')    data = re.sub(r'("(?:[^\\"]|\\.)*")', r'u\1', data)    data = re.sub(',{2,}', ',', data)        result = []    try:        exec data in {'__builtins__': None}, {'D': lambda x: result.append(x)}    except SyntaxError,info:        print info        raise GmailError, 'Failed to parse data returned from gmail.'    items = result     itemsDict = {}    namesFoundTwice = []    for item in items:        name = item[0]        try:            parsedValue = item[1:]        except Exception:            parsedValue = ['']        if itemsDict.has_key(name):            # This handles the case where a name key is used more than            # once (e.g. mail items, mail body etc) and automatically            # places the values into list.            # TODO: Check this actually works properly, it's early... :-)                        if len(parsedValue) and type(parsedValue[0]) is types.ListType:                    for item in parsedValue:                        itemsDict[name].append(item)            else:                itemsDict[name].append(parsedValue)        else:            if len(parsedValue) and type(parsedValue[0]) is types.ListType:                    itemsDict[name] = []                    for item in parsedValue:                        itemsDict[name].append(item)            else:                itemsDict[name] = [parsedValue]    return itemsDictdef _splitBunches(infoItems):# Is this still needed ?? Stas    """    Utility to help make it easy to iterate over each item separately,    even if they were bunched on the page.    """    result= []    # TODO: Decide if this is the best approach.    for group in infoItems:        if type(group) == tuple:            result.extend(group)        else:            result.append(group)    return resultclass SmartRedirectHandler(ClientCookie.HTTPRedirectHandler):    def __init__(self, cookiejar):        self.cookiejar = cookiejar    def http_error_302(self, req, fp, code, msg, headers):        # The location redirect doesn't seem to change        # the hostname header appropriately, so we do        # by hand. (Is this a bug in urllib2?)        new_host = re.match(r'http[s]*://(.*?\.google\.com)',                            headers.getheader('Location'))        if new_host:            req.add_header("Host", new_host.groups()[0])        result = ClientCookie.HTTPRedirectHandler.http_error_302(            self, req, fp, code, msg, headers)                      return result           def _buildURL(**kwargs):    """    """    return "%s%s" % (URL_GMAIL, urllib.urlencode(kwargs))def _paramsToMime(params, filenames, files):    """    """    mimeMsg = MIMEMultipart("form-data")    for name, value in params.iteritems():        mimeItem = MIMEText(value)        mimeItem.add_header("Content-Disposition", "form-data", name=name)        # TODO: Handle this better...?        for hdr in ['Content-Type','MIME-Version','Content-Transfer-Encoding']:            del mimeItem[hdr]        mimeMsg.attach(mimeItem)    if filenames or files:        filenames = filenames or []        files = files or []        for idx, item in enumerate(filenames + files):            # TODO: This is messy, tidy it...            if isinstance(item, str):                # We assume it's a file path...                filename = item                contentType = mimetypes.guess_type(filename)[0]                payload = open(filename, "rb").read()            else:                # We assume it's an `email.Message.Message` instance...                # TODO: Make more use of the pre-encoded information?                filename = item.get_filename()                contentType = item.get_content_type()                payload = item.get_payload(decode=True)                            if not contentType:                contentType = "application/octet-stream"                            mimeItem = MIMEBase(*contentType.split("/"))            mimeItem.add_header("Content-Disposition", "form-data",                                name="file%s" % idx, filename=filename)            # TODO: Encode the payload?            mimeItem.set_payload(payload)            # TODO: Handle this better...?            for hdr in ['MIME-Version','Content-Transfer-Encoding']:                del mimeItem[hdr]            mimeMsg.attach(mimeItem)    del mimeMsg['MIME-Version']    return mimeMsgclass GmailLoginFailure(Exception):    """    Raised whenever the login process fails--could be wrong username/password,    or Gmail service error, for example.    Extract the error message like this:    try:        foobar     except GmailLoginFailure,e:        mesg = e.message# or        print e# uses the __str__    """    def __init__(self,message):        self.message = message    def __str__(self):        return repr(self.message)class GmailAccount:    """    """    def __init__(self, name = "", pw = "", state = None, domain = None):        global URL_LOGIN, URL_GMAIL        """        """        self.domain = domain        if self.domain:            URL_LOGIN = "https://www.google.com/a/" + self.domain + "/LoginAction2"            URL_GMAIL = "http://mail.google.com/a/" + self.domain + "/?ui=1&"        else:            URL_LOGIN = GMAIL_URL_LOGIN            URL_GMAIL = GMAIL_URL_GMAIL        if name and pw:            self.name = name            self._pw = pw            self._cookieJar = ClientCookie.LWPCookieJar()            opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(self._cookieJar))            ClientCookie.install_opener(opener)                        if PROXY_URL is not None:                import gmail_transport                self.opener = ClientCookie.build_opener(gmail_transport.ConnectHTTPHandler(proxy = PROXY_URL),                                  gmail_transport.ConnectHTTPSHandler(proxy = PROXY_URL),                                  SmartRedirectHandler(self._cookieJar))            else:                self.opener = ClientCookie.build_opener(                                ClientCookie.HTTPHandler(),                                ClientCookie.HTTPSHandler(),                                SmartRedirectHandler(self._cookieJar))        elif state:            # TODO: Check for stale state cookies?            self.name, self._cookieJar = state.state        else:            raise ValueError("GmailAccount must be instantiated with " \                             "either GmailSessionState object or name " \                             "and password.")        self._cachedQuotaInfo = None        self._cachedLabelNames = None            def login(self):        """        """        # TODO: Throw exception if we were instantiated with state?        if self.domain:            data = urllib.urlencode({'continue': URL_GMAIL,                                     'at'      : 'null',                                     'service' : 'mail',                                     'Email': self.name,                                     'Passwd': self._pw,                                     })        else:            data = urllib.urlencode({'continue': URL_GMAIL,                                     'Email': self.name,                                     'Passwd': self._pw,                                     })                                                   headers = {'Host': 'www.google.com',                   'User-Agent': 'Mozilla/5.0 (Compatible; libgmail-python)'}        req = ClientCookie.Request(URL_LOGIN, data=data, headers=headers)        pageData = self._retrievePage(req)                if not self.domain:        # The GV cookie no longer comes in this page for        # "Apps", so this bottom portion is unnecessary for it.            # This requests the page that provides the required "GV" cookie.            RE_PAGE_REDIRECT = 'CheckCookie\?continue=([^"\']+)'                     # TODO: Catch more failure exceptions here...?            try:                link = re.search(RE_PAGE_REDIRECT, pageData).group(1)                redirectURL = urllib2.unquote(link)                redirectURL = redirectURL.replace('\\x26', '&')                        except AttributeError:                raise GmailLoginFailure("Login failed. (Wrong username/password?)")            # We aren't concerned with the actual content of this page,            # just the cookie that is returned with it.            pageData = self._retrievePage(redirectURL)    def getCookie(self,cookiename):        # TODO: Is there a way to extract the value directly?        for index, cookie in enumerate(self._cookieJar):            if cookie.name == cookiename:                return cookie.value        return ""    def _retrievePage(self, urlOrRequest):        """        """        if self.opener is None:            raise "Cannot find urlopener"                # ClientCookieify it, if it hasn't been already        if not isinstance(urlOrRequest, urllib2.Request):            req = ClientCookie.Request(urlOrRequest)        else:            req = urlOrRequest        req.add_header('User-Agent',                       'Mozilla/5.0 (Compatible; libgmail-python)')                try:            resp = self.opener.open(req)        except urllib2.HTTPError,info:            print info            return None        pageData = resp.read()        # TODO: This, for some reason, is still necessary?        self._cookieJar.extract_cookies(resp, req)        # TODO: Enable logging of page data for debugging purposes?        return pageData    def _parsePage(self, urlOrRequest):        """        Retrieve & then parse the requested page content.                """        items = _parsePage(self._retrievePage(urlOrRequest))        # Automatically cache some things like quota usage.        # TODO: Cache more?        # TODO: Expire cached values?        # TODO: Do this better.        try:            self._cachedQuotaInfo = items[D_QUOTA]        except KeyError:            pass        #pprint.pprint(items)                try:            self._cachedLabelNames = [category[CT_NAME] for category in items[D_CATEGORIES][0]]        except KeyError:            pass                return items    def _parseSearchResult(self, searchType, start = 0, **kwargs):        """        """        params = {U_SEARCH: searchType,                  U_START: start,                  U_VIEW: U_THREADLIST_VIEW,                  }        params.update(kwargs)        return self._parsePage(_buildURL(**params))    def _parseThreadSearch(self, searchType, allPages = False, **kwargs):        """        Only works for thread-based results at present. # TODO: Change this?        """        start = 0        tot = 0        threadsInfo = []        # Option to get *all* threads if multiple pages are used.        while (start == 0) or (allPages and                               len(threadsInfo) < threadListSummary[TS_TOTAL]):                            items = self._parseSearchResult(searchType, start, **kwargs)                #TODO: Handle single & zero result case better? Does this work?

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲免费在线一区| 国产在线精品一区在线观看麻豆| 国产高清成人在线| 久久久99精品免费观看| 国产99久久久精品| 亚洲欧洲国产日韩| 在线免费一区三区| 丝袜美腿亚洲综合| 久久综合狠狠综合| 成人精品免费网站| 一区二区三区高清| 91精品欧美综合在线观看最新| 日韩在线一区二区三区| 日韩一区二区三区在线观看| 日韩不卡手机在线v区| 精品久久久久久综合日本欧美| 国产精品一区在线观看你懂的| 国产精品私人影院| 99久久综合国产精品| 亚洲精品国产视频| 日韩欧美综合在线| 成人性视频免费网站| 亚洲最新视频在线观看| 欧美成人一区二区| fc2成人免费人成在线观看播放| 亚洲综合一区二区| 宅男噜噜噜66一区二区66| 精品一区二区三区香蕉蜜桃| 亚洲图片激情小说| 日韩免费观看2025年上映的电影| 国产成人一级电影| 午夜久久久久久久久| 久久先锋资源网| 91福利精品视频| 久久9热精品视频| 亚洲精品免费在线观看| 久久蜜桃av一区精品变态类天堂| 91丨porny丨国产入口| 久久精品国产99久久6| 1024成人网| 久久精品这里都是精品| 欧美巨大另类极品videosbest | 欧美精品乱人伦久久久久久| 国产一区二区三区四区在线观看| 亚洲日本在线天堂| 久久免费视频色| 欧美二区乱c少妇| 91在线视频18| 国产传媒日韩欧美成人| 首页国产丝袜综合| 亚洲精品乱码久久久久久黑人| 久久久久久久久一| 在线综合亚洲欧美在线视频| 日本乱码高清不卡字幕| 成人污污视频在线观看| 久久成人av少妇免费| 午夜精品成人在线视频| 自拍偷拍亚洲综合| 欧美激情一区二区三区在线| 欧美tickling挠脚心丨vk| 欧美三级一区二区| av不卡在线观看| 国产成人av资源| 精品一区二区三区免费毛片爱| 婷婷六月综合亚洲| 亚洲国产一区二区视频| 中文字幕中文字幕中文字幕亚洲无线| 精品国产乱码久久久久久久久| 欧美日韩高清在线播放| 99精品视频在线观看免费| 国产成人精品免费视频网站| 国产在线视频一区二区三区| 久久精品av麻豆的观看方式| 婷婷久久综合九色综合绿巨人| 亚洲一区二区三区小说| 亚洲黄色录像片| 亚洲国产一区二区三区 | 在线免费观看不卡av| 91视频你懂的| 色诱亚洲精品久久久久久| 91女神在线视频| 色吊一区二区三区| 欧美亚洲高清一区二区三区不卡| 一本在线高清不卡dvd| 91福利在线导航| 欧美三级韩国三级日本一级| 欧美美女黄视频| 制服丝袜中文字幕一区| 日韩一区二区电影| 精品国产亚洲一区二区三区在线观看| 日韩欧美一区二区免费| 精品粉嫩超白一线天av| 国产欧美精品一区| 亚洲欧洲精品天堂一级| 一区二区三区在线观看国产| 午夜电影网亚洲视频| 日本91福利区| 国产精品77777| 色综合天天综合色综合av| 欧美日韩一区二区三区高清| 日韩一区二区三区电影| 国产亚洲一二三区| 一区二区三区在线观看视频 | 在线成人av网站| 欧美精品一区男女天堂| 中文字幕第一区综合| 亚洲激情男女视频| 美日韩黄色大片| 成人永久看片免费视频天堂| 色哟哟亚洲精品| 91麻豆精品国产91久久久资源速度| 久久综合久久久久88| 国产精品成人网| 免费一级欧美片在线观看| 成人精品免费看| 欧美日韩高清影院| 欧美国产精品一区二区| 亚洲一区二区视频在线观看| 精油按摩中文字幕久久| 99国产欧美久久久精品| 日韩久久久久久| 亚洲免费看黄网站| 久久er99精品| 欧日韩精品视频| 久久久久久97三级| 亚洲18色成人| 成人一区二区三区视频在线观看| 欧美最猛黑人xxxxx猛交| 2023国产一二三区日本精品2022| 亚洲欧美一区二区视频| 美女精品一区二区| 日本久久一区二区三区| 久久影音资源网| 亚洲aⅴ怡春院| 91在线观看视频| 久久久亚洲精华液精华液精华液| 亚洲成人你懂的| 99国产欧美另类久久久精品| 欧美精品一区二区三区高清aⅴ | 精品成人在线观看| 一区二区三区在线免费观看| 国产九九视频一区二区三区| 欧美日韩国产成人在线免费| ...中文天堂在线一区| 国产一区二区在线观看视频| 欧美视频完全免费看| 国产精品久久久久久户外露出 | 国产精品区一区二区三区| 热久久免费视频| 欧美性猛交xxxxxxxx| 国产精品理伦片| 粉嫩一区二区三区性色av| 欧美大片国产精品| 日韩在线一二三区| 欧美日本一道本在线视频| 亚洲欧美日韩国产一区二区三区| 国产一区二区看久久| 日韩视频中午一区| 午夜电影久久久| 7878成人国产在线观看| 亚洲国产成人精品视频| 色综合久久综合网欧美综合网| 欧美国产精品一区二区| 国产成人在线视频播放| 国产亚洲视频系列| 高清国产午夜精品久久久久久| 久久蜜桃香蕉精品一区二区三区| 久久99精品国产麻豆婷婷洗澡| 在线不卡免费av| 日韩精品成人一区二区三区| 56国语精品自产拍在线观看| 一区二区三区精品久久久| 欧美在线视频日韩| 亚洲综合色网站| 在线观看一区不卡| 亚洲一区二区三区视频在线播放 | 91精品国产福利在线观看 | 亚洲一区在线视频观看| 色综合久久88色综合天天6| 亚洲欧美日韩久久精品| 欧美偷拍一区二区| 亚洲高清视频在线| 91精品婷婷国产综合久久 | 亚洲情趣在线观看| 在线精品观看国产| 亚洲成a人v欧美综合天堂| 欧美精品乱码久久久久久| 免费在线观看一区| 久久麻豆一区二区| av一本久道久久综合久久鬼色| 亚洲精品视频观看| 51精品久久久久久久蜜臀| 精一区二区三区| 国产精品日产欧美久久久久| 在线免费观看视频一区| 午夜精品福利一区二区三区av| 精品精品国产高清一毛片一天堂| 久久国产夜色精品鲁鲁99| 国产精品日韩精品欧美在线| 欧美午夜一区二区三区免费大片|