python爬取exchange

in python with 0 comment

import urllib3, datetime
from exchangelib import DELEGATE, Account, Credentials, BaseProtocol, NoVerifyHTTPAdapter
def reade():
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
    creds = Credentials('[email protected]', 'password')
    account = Account('primary_smtp_address', credentials=creds, autodiscover=True, access_type=DELEGATE)
    return [[i.subject for i in item.all().order_by('-datetime_received')[:66] if str(i.datetime_received).split()[0].replace('-','') == now] for item in account.inbox.children if item.name == '文件夹名']
now = datetime.datetime.now().strftime('%Y%m%d')
[print(i) for i in reade()[0]]
Comments are closed.