Created
October 23, 2014 13:48
-
-
Save dchaplinsky/25b7ae950cbac4e39e70 to your computer and use it in GitHub Desktop.
This file contains 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 MySQLdb | |
import json | |
import html2text | |
con = MySQLdb.connect('localhost', 'root', '', 'nashig', use_unicode=True) | |
with con: | |
h = html2text.HTML2Text() | |
h.ignore_links = True | |
cur = con.cursor() | |
cur.execute("SELECT post_title, post_content from wp_posts") | |
with open("lines.json", "w") as fp: | |
for title, content in cur.fetchall(): | |
fp.write(json.dumps({ | |
"title": h.handle(title).strip(), | |
"content": h.handle(content).strip() | |
}) + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment