Last active
December 25, 2015 22:59
-
-
Save elin-moco/7053450 to your computer and use it in GitHub Desktop.
Render google form in django views.py
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 urllib2 | |
from BeautifulSoup import BeautifulSoup | |
from django.shortcuts import render | |
def google_form(request, template='reg/gform.html', formkey=None): | |
gform = '' | |
if formkey: | |
soup = BeautifulSoup(urllib2.urlopen('https://docs.google.com/spreadsheet/viewform?formkey=%s' % formkey).read()) | |
formResult = soup('div', {'class': 'ss-form-container'}) | |
for div in formResult: | |
gform += div.prettify('utf-8').decode('utf-8') | |
context = { | |
'gform': gform, | |
} | |
return render(request, template, context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment