Skip to content

Instantly share code, notes, and snippets.

@wbrgss
Created December 4, 2016 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbrgss/bd0ae99c632c9a4edc7f5405edf576ce to your computer and use it in GitHub Desktop.
Save wbrgss/bd0ae99c632c9a4edc7f5405edf576ce to your computer and use it in GitHub Desktop.
GetForm File Downloader
import requests
from requests import get
import os
import xlrd
# enter your GetForm auth details
payload = {
'username': '[usename]',
'password': '[password]'
}
# replace the default filename GetFormExport if you renamed the XLS file
sh = xlrd.open_workbook('GetFormExport').sheet_by_index(0)
url = "https://getform.org/DOWNLOAD?name="
if not os.path.exists('uploads'):
uploads = os.mkdir('uploads')
# Use 'with' to ensure the session context is closed after use
with requests.Session() as s:
p = s.post('https://getform.org/j_spring_security_check', data=payload)
# will print {"result1":"{{youremail@mail.com}}","redirect":"forms"} if login is successful
print(p.text)
for rownum in range(sh.nrows):
filename = str(sh.cell(rownum, 17).value)
filedir = os.path.join('uploads', filename)
with open(filedir, "wb") as file:
# get request
response = s.get(url+filename)
# write to file
file.write(response.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment