Skip to main content

Google Forms wrapper for Python

Project description

GForms

A python wrapper for public Google Forms.

This package does not implement form editing / sharing / other actions with user-owned forms

Installation

python3 -m pip install gforms

Features

  • Form parsing
    • All form settings are parsed
    • Multi-page forms are supported
    • Elements with input validation are supported
  • Form filling
    • Fill the entire form using a single callback function (see example)
    • Fill individual elements
    • Validate the form before submission
  • Form submission
    • Faster submission for multi-page forms (history emulation)

Limitations

  • Forms with required sign-in cannot be submitted
  • Forms with file upload cannot be parsed (sign-in is required for loading the form)
  • A CAPTCHA needs to be solved in order to send an e-mail with a response copy (when this option is enabled). CAPTCHA handling should be implemented separately
  • Form style is not parsed

Example

See example.py for more details.

from gforms import Form
from gforms.elements import Short, Value

def callback(element, page_index, element_index):
    # fill an element based on its position
    if page_index == 0 and element_index == 1:
        return 'Yes'
    # fill an element based on its type and name
    if isinstance(element, Short) and element.name == 'Your opinion:':
        return input(element.name)
    # fill choice elements with random values, skip optional elements if fill_optional is not used
    return Value.DEFAULT

url = 'https://docs.google.com/forms/d/e/.../viewform'

form = Form()

form.load(url)
print(form.to_str(indent=2))  # a text representation, may be useful for CLI applications

form.fill(callback)
form.submit()

# Faster submission for multi-page forms (use only one POST request)
# (in theory, you may get banned, but now the actual number of requests isn't checked)
form.submit(emulate_history=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gforms-1.2.3.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gforms-1.2.3-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file gforms-1.2.3.tar.gz.

File metadata

  • Download URL: gforms-1.2.3.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for gforms-1.2.3.tar.gz
Algorithm Hash digest
SHA256 97bbcdd353a3d3e25e1bd26221e1db0078c5c32299a82c5d4648d7b23fd71e69
MD5 e11886f5b3ade5a79591a3d743f07493
BLAKE2b-256 f371501f4f03bf50f1c5640eb4ef2fa861416022348984a271d79ac8c070a47d

See more details on using hashes here.

File details

Details for the file gforms-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: gforms-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for gforms-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd9a608bc3baa61d765dc00f6e5f4596d699d34e5a3e59dc77c9e7d21b2362cd
MD5 3c9ba33550d9cbbccdf06b637fcef60b
BLAKE2b-256 e4a3d63539ffa002c3a3500e6c1dbae4380274a883713614f5f86d4973aa4dfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page