Last active
December 20, 2015 01:49
-
-
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.
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
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