Skip to content

Instantly share code, notes, and snippets.

@cgutierrez
Created January 8, 2012 20:27
Show Gist options
  • Save cgutierrez/1579557 to your computer and use it in GitHub Desktop.
Save cgutierrez/1579557 to your computer and use it in GitHub Desktop.
Save Hi-Res QR codes
from zope.testbrowser.browser import Browser
from time import sleep
storyIds = range(1, 201)
rootUrl = "http://example.com/%s"
for storyId in storyIds:
url = rootUrl % (storyId)
browser = Browser("http://qrickit.com/qrickit_apps/qrickit_qrcode_creator_url.php")
qrForm = browser.getForm(action = "qrickit_qrcode_creator_url_output.php")
# populate the url field
urlInput = qrForm.getControl(name = "url")
urlInput.value = url
qrForm.submit(name = "submit")
# submit the high res form to get the image
qrHighResForm = browser.getForm(name = "form2")
qrHighResForm.submit(name = "submit2")
f = open("img/%s.jpg" % (storyId), "wb")
f.write(browser.contents)
f.close()
# try not to get rate limited
sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment