Created
August 21, 2013 21:00
-
-
Save jkeyes/6300216 to your computer and use it in GitHub Desktop.
Docraptor async example
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 time | |
from docraptor import DocRaptor | |
docraptor = DocRaptor() | |
print "Create PDF" | |
# resp = docraptor.create({ | |
# 'document_content': '<h1>python-docraptor</h1><p>Async Test</p>', | |
# 'test': True, | |
# 'async': True | |
# }) | |
resp = docraptor.create({ | |
'document_content': "<html><p>test</p></html>", | |
'test': True, | |
'async': True, | |
'name': "test doc", | |
'javascript': True | |
}) | |
print "Status ID: %s" % (resp['status_id']) | |
status_id = resp['status_id'] | |
resp = docraptor.status(status_id) | |
print " %s" % (resp['status']) | |
while resp['status'] != 'completed': | |
time.sleep(3) | |
resp = docraptor.status(status_id) | |
print " %s" % (resp['status']) | |
print "Download to test_async.pdf", | |
with open("test_async.pdf", "wb") as f: | |
f.write(docraptor.download(resp['download_key']).content) | |
print "[DONE]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment