当前位置: 首页>>代码示例>>Python>>正文


Python imaplib._MAXLINE属性代码示例

本文整理汇总了Python中imaplib._MAXLINE属性的典型用法代码示例。如果您正苦于以下问题:Python imaplib._MAXLINE属性的具体用法?Python imaplib._MAXLINE怎么用?Python imaplib._MAXLINE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在imaplib的用法示例。


在下文中一共展示了imaplib._MAXLINE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unsub_scan

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def unsub_scan(user_name, user_pass):
    """Returns a list of the unsubscribe links in a Gmail inbox."""
    unsub_links = []
    imaplib._MAXLINE = 10000000
    imap_obj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
    imap_obj.login(user_name, user_pass)
    imap_obj.select_folder('INBOX', readonly=True)
    unique_ids = imap_obj.search(['ALL'])

    for identifier in unique_ids:
        raw_message = imap_obj.fetch([identifier], ['BODY[]', 'FLAGS'])
        message = pyzmail.PyzMessage.factory(raw_message[identifier][b'BODY[]'])
        html = message.html_part.get_payload().decode(message.html_part.charset)
        soup = bs4.BeautifulSoup(html, 'lxml')
        link_elems = soup.select('a')
        for selected in link_elems:
            if 'unsubscribe' in str(selected):
                unsub_links.append(selected.get('href'))

    imap_obj.logout()

    return unsub_links 
开发者ID:IFinners,项目名称:automate-the-boring-stuff-projects,代码行数:24,代码来源:auto_unsubscriber.py

示例2: test_linetoolong

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def test_linetoolong(self):
        class TooLongHandler(SimpleIMAPHandler):
            def handle(self):
                # Send a very long response line
                self.wfile.write('* OK ' + imaplib._MAXLINE*'x' + '\r\n')

        with self.reaped_server(TooLongHandler) as server:
            self.assertRaises(imaplib.IMAP4.error,
                              self.imap_class, *server.server_address) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:11,代码来源:test_imaplib.py

示例3: test_linetoolong

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def test_linetoolong(self):
        class TooLongHandler(SimpleIMAPHandler):
            def handle(self):
                # Send a very long response line
                self.wfile.write(b'* OK ' + imaplib._MAXLINE * b'x' + b'\r\n')

        with self.reaped_server(TooLongHandler) as server:
            self.assertRaises(imaplib.IMAP4.error,
                              self.imap_class, *server.server_address) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_imaplib.py

示例4: test_linetoolong

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def test_linetoolong(self):
        class TooLongHandler(SimpleIMAPHandler):
            def handle(self):
                # Send a very long response line
                self.wfile.write(b'* OK ' + imaplib._MAXLINE*b'x' + b'\r\n')

        with self.reaped_server(TooLongHandler) as server:
            self.assertRaises(imaplib.IMAP4.error,
                              self.imap_class, *server.server_address) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_imaplib.py

示例5: unsubscribe

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def unsubscribe(imap_address, email_address, password):
    """Checks unsubscribe links within emails and opens link
    Args:
        imap_address (str): email providers imap address
        email_address (str): email address
        password (str): password for email
    Returns:
        None
    """
    imaplib._MAXLINE = 10000000
    imapObj = imapclient.IMAPClient(imap_address, ssl=True)
    # See https://support.google.com/accounts/answer/6010255 if (Login Error)
    imapObj.login(email_address, password)
    imapObj.select_folder('INBOX', readonly=True)
    UIDs = imapObj.search(['ALL'])

    for u in UIDs:
        rawMessages = imapObj.fetch([u], ['BODY[]', 'FLAGS'])
        message = pyzmail.PyzMessage.factory(rawMessages[u][b'BODY[]'])

        if message.html_part:
            html = message.html_part.get_payload().decode(message.html_part.charset)
            soup = bs4.BeautifulSoup(html, 'html.parser')
            linkElems = soup.select('a')

            for link in linkElems:
    
                if 'unsubscribe' in link.text.lower():
                    url = link.get('href')
                    print('opening {}: '.format(url))
                    webbrowser.open(url)

    imapObj.logout() 
开发者ID:kudeh,项目名称:automate-the-boring-stuff-projects,代码行数:35,代码来源:unsubscriber.py

示例6: check_for_torrents

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import _MAXLINE [as 别名]
def check_for_torrents(imap_address, email_address, password, verified_creds):
    """Checks email for torrent links from verified accounts
    Args:
        imap_address (str): email providers imap address
        email_address (str): email address
        password (str): password for email
        verified_creds (dict): dict containing verfied email and password
    """
    imaplib._MAXLINE = 10000000
    imapObj = imapclient.IMAPClient(imap_address, ssl=True)
    # See https://support.google.com/accounts/answer/6010255 if (Login Error)
    imapObj.login(email_address, password)
    imapObj.select_folder('INBOX', readonly=True)
    UIDs = imapObj.search(['FROM ' + verified_creds['email']])

    links = []
    if UIDs:
        for u in UIDs:
            rawMessages = imapObj.fetch([u], ['BODY[]', 'FLAGS'])
            message = pyzmail.PyzMessage.factory(rawMessages[u][b'BODY[]'])
            text = message.text_part.get_payload().decode(message.text_part.charset)

            if verified_creds['password'] in text:
                html = message.html_part.get_payload().decode(message.html_part.charset)
                links.append(html)

        imapObj.delete_messages(UIDs)
        imapObj.expunge()
    
    imapObj.logout()

    return links 
开发者ID:kudeh,项目名称:automate-the-boring-stuff-projects,代码行数:34,代码来源:download_torrent.py


注:本文中的imaplib._MAXLINE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。