示例#1
0
            cardTitle = mergeStringContent(environment)
            card = createSanitizedCard(cardCategory, cardTitle, cardLink)
            cards.append(card)

    postSize = len(cards)
    print("added " + str(postSize - preSize) + " cards for category : " +
          cardCategory)


if __name__ == '__main__':
    print("Make sure Firefox is running !")

    cards = []
    # the timeout argument in the constructor may have to be increased - if errors occur
    timeout = 1
    browser = ContentRetrieverUsingSelenium(timeout)

    try:
        createGeneralCards(cards, browser, ['h3', 'h2'],
                           'https://golang.org/doc/install', 'Getting Started')
        addTourCards(cards, browser)
        createGeneralCards(cards, browser, ['h3', 'h2'],
                           'https://golang.org/ref/mem', 'The Go Memory Model')
        createGeneralCards(cards, browser, ['h3', 'h2'],
                           'https://golang.org/doc/code.html',
                           'How to Write Go Code')
        createGeneralCards(cards, browser, ['h3', 'h2'],
                           'https://golang.org/doc/effective_go.html',
                           'Effective Go')
        createGeneralCards(cards, browser, ['h3', 'h2'],
                           'https://golang.org/doc/faq',
            cardLink = url + "#" + linkId

            cardTitle = mergeStringContent(environment)
            card = createSanitizedCard(cardCategory, cardTitle, cardLink)
            cards.append(card)

    postSize = len(cards)
    print("added " + str(postSize - preSize) + " cards for category : " + cardCategory)


if __name__ == "__main__":
    print("Make sure Firefox is running !")

    cards = []
    # the timeout argument in the constructor may have to be increased - if errors occur
    timeout = 1
    browser = ContentRetrieverUsingSelenium(timeout)

    try:
        createGeneralCards(cards, browser, ["h3", "h2"], "https://golang.org/doc/install", "Getting Started")
        addTourCards(cards, browser)
        createGeneralCards(cards, browser, ["h3", "h2"], "https://golang.org/ref/mem", "The Go Memory Model")
        createGeneralCards(cards, browser, ["h3", "h2"], "https://golang.org/doc/code.html", "How to Write Go Code")
        createGeneralCards(cards, browser, ["h3", "h2"], "https://golang.org/doc/effective_go.html", "Effective Go")
        createGeneralCards(cards, browser, ["h3", "h2"], "https://golang.org/doc/faq", "Frequently Asked Questions")

    finally:
        browser.close()

    createCSVFile("golang", cards)
from ankiflashcardcreationtools.CrawlTools import ContentRetrieverUsingSelenium, mergeStringContent
from ankiflashcardcreationtools.CardTools import createSanitizedCard, createCSVFile


if __name__ == "__main__":
    print("Make sure Firefox is running !")

    cards = []
    timeout = 1.5
    baseUrl = "https://docs.python.org/3/tutorial/"
    startUrl = baseUrl + "index.html"
    cardCategory = "Python 3"

    browser = ContentRetrieverUsingSelenium(timeout)

    try:
        _, content = browser.getContentOfPage(startUrl)
        tocTree = content.find("div", {"class": "toctree-wrapper"})
        links = tocTree.find_all("a", {"class": "reference internal"})

        for link in links:
            cardTitle = mergeStringContent(link)
            cardLink = baseUrl + link.attrs["href"]
            card = createSanitizedCard(cardCategory, cardTitle, cardLink)
            cards.append(card)
    finally:
        browser.close()

    print("finished collecting " + str(len(cards)))
    createCSVFile("python3", cards)
示例#4
0
from ankiflashcardcreationtools.CrawlTools import ContentRetrieverUsingSelenium,\
    mergeStringContent
from ankiflashcardcreationtools.CardTools import createSanitizedCard,\
    createCSVFile

if __name__ == '__main__':
    print("Make sure Firefox is running !")

    cards = []
    timeout = 1.5
    baseUrl = 'https://docs.python.org/3/tutorial/'
    startUrl = baseUrl + 'index.html'
    cardCategory = 'Python 3'

    browser = ContentRetrieverUsingSelenium(timeout)

    try:
        _, content = browser.getContentOfPage(startUrl)
        tocTree = content.find('div', {'class': 'toctree-wrapper'})
        links = tocTree.find_all('a', {'class': 'reference internal'})

        for link in links:
            cardTitle = mergeStringContent(link)
            cardLink = baseUrl + link.attrs['href']
            card = createSanitizedCard(cardCategory, cardTitle, cardLink)
            cards.append(card)
    finally:
        browser.close()

    print("finished collecting " + str(len(cards)))
    createCSVFile("python3", cards)