Created
March 20, 2018 18:58
-
-
Save nehalvpatel/47161f18aad809c5954775c1daa82598 to your computer and use it in GitHub Desktop.
Rudimentary script to parse and format MindTap flashcards for Quizlet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json, re, sys | |
| from bs4 import BeautifulSoup | |
| input_file = sys.argv[1] | |
| with open(input_file, encoding="utf8") as json_handle: | |
| data = json.load(json_handle) | |
| for card in data[0]: | |
| term_html = card['term'] | |
| term_soup = BeautifulSoup(term_html, "html.parser") | |
| term = term_soup.get_text() | |
| definition_html = card["definition"] | |
| definition_soup = BeautifulSoup(definition_html, "html.parser") | |
| definition = definition_soup.get_text() | |
| print("%s~~~~%s^^^^" % (term, definition)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment