Skip to content

Instantly share code, notes, and snippets.

@interstar
Last active December 20, 2015 01:49
Show Gist options
  • Save interstar/6051618 to your computer and use it in GitHub Desktop.
Save interstar/6051618 to your computer and use it in GitHub Desktop.
Quora Scraper: And here's a quick page which takes the files containing my answers that I pulled via RSS and makes an HTML page out of them.
from os import listdir
from os.path import isfile, join
onlyfiles = [ f for f in listdir(".") if isfile(join("",f)) ]
import json
print """
<html>
<style>
body {
font-family:sans;
color:#333333;
padding:3px;
}
dt {
top-margin:4px;
}
</style>
<body>
<h2>Quora Answers by MY NAME</h2>
<dl>
"""
for fn in onlyfiles :
if fn[-3:] == "txt":
f = open(fn)
entry = json.loads(f.read())
print "<dt>%s <a href='%s'>Link</a></dt>" % (entry["question"].encode("utf-8"), entry["link"].encode("utf-8"))
answer = entry["answer"].encode("utf-8")
answer = answer.replace("\n\n","<br/>")
print "<dd>%s</dd>" % answer
print """
</dl>
</body>
</html>"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment