Пример #1
0
##    else:
##    print "SUCCEEDED as expected"
##
##    adox = Dispatch ("ADOX.Catalog")
##    adox.ActiveConnection = db
##    adox.Tables ("dtest").Columns ("data").Name = "newdata"
##    adox.Tables.Refresh ()
##    finally:
##    db.Close ()
##
##    db = Dispatch ('ADODB.Connection')
##    db.Open (CONNECTION_STRING)
##    try:
##
##    try:
##    db.Execute ('SELECT id, data FROM dtest')
##    except:
##    print "FAILED as expected"
##    else:
##    print "SUCCEEDED unexpectedly"
##
##    try:
##    db.Execute ('SELECT id, newdata FROM dtest')
##    except:
##    print "FAILED unexpectedly"
##    else:
##    print "SUCCEEDED as expected"
##
finally:
    db.Close ()
Пример #2
0
from win32com.client.gencache import EnsureDispatch as Dispatch

URL = "https://community.articulate.com/series/storyline-3"
HOME_URL = "https://community.articulate.com"

with requests.Session() as s:
    r = s.get(URL)
    html = BeautifulSoup(r.text, "html.parser")
    sections = html.find("div", {
        "class": "post__body series__body"
    }).find_all("section", {"class": "series__section"})
    message = Dispatch("CDO.Message")
    message.CreateMHTMLBody(URL)
    stream = Dispatch(message.GetStream())
    stream.SaveToFile("main page.mht", 2)
    stream.Close()
    for sec in sections:
        ftag = sec.find("h2")
        links = sec.find("nav").find("ol").find_all("li")
        fpath = ""
        if ftag is not None:
            fpath = ftag.string
        else:
            fpath = "Getting Started"
        os.mkdir(fpath)
        for link in links:
            u = link.find("a")["href"]
            fname = u.split("/")[len(u.split("/")) - 1]
            message = Dispatch("CDO.Message")
            message.CreateMHTMLBody(HOME_URL + u)
            stream = Dispatch(message.GetStream())