Created
December 4, 2016 20:17
-
-
Save wbrgss/bd0ae99c632c9a4edc7f5405edf576ce to your computer and use it in GitHub Desktop.
GetForm File Downloader
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 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