Giter Site home page Giter Site logo

googleform-autofill-and-submit's Introduction

🚀 Google Form AutoFill and Submit

Vietnamese version here

Someone send us a Google-form, and we need to fill it everyday or maybe every hour to report something. It seems to be boring, so I just think to write a script to build this auto-bot using Python 3

This is a simple and lightweight script to automatically fill and submit a Google form. It's also include a request body generator, you can simply copy and paste a Google form URL, eliminating the need for manual inspection.

This document will guide you through the process of creating a Python script to automatically fill and submit a Google form.

Prerequisites

  • Python 3.x
  • requests library (pip install requests or pip install -r requirements.txt)

Just build it

Create and access URL

The URL of the Google form will look like this:

https://docs.google.com/forms/d/e/form-index/viewform

Just copy it and replace viewform to formResponse

https://docs.google.com/forms/d/e/form-index/formResponse

Extract information

Automatically

Just copy the Google form URL and run form.py script. The script will return a dictionary which contains the name attributes of each input element and the data you need to fill out.

python form.py <your-gg-form-url>

The result will be printed to the console (by default) or saved to a file if the -o option is used.

For more information use the help command

python form.py -h

Example:

python form.py 'https://docs.google.com/forms/u/0/d/e/1FAIpQLSdwcwvrOeBG200L0tCSUHc1MLebycACWIi3qw0UBK31GE26Yg/formResponse' -o results.txt

Manually

Open the Google form, then open DevTools (inspect) for inspecting the input element.

Each of the input elements which we need to fill data has format: name = "entry.id"

Try to fill each input box to know its id

Note:

  • If the form requires email, please add the emailAddress field
  • For multiple pages form, please add the pageHistory field with a comma-separated list of page numbers (starting from 0) if the form has multiple pages. For example, a 4-page form would have "pageHistory": "0,1,2,3"

Write the Python script

Fill form

Create a dictionary in which keys are the name attributes of each input element, and values are the data you need to fill out

def fill_form():
    name = get_name_by_day()
    date, hour = str(get_gmt_time()).split(' ')
    date = date.split('-')
    hour = hour.split(':')
    if (int(hour[0]) < 10):
        hour[0] = hour[0][1:]

    value = {
         # Text
        "entry.2112281434": name,
        # Dropdown menu
        "entry.1600556346": "Sài Gòn",
        # Date
        "entry.77071893_year": date[0],
        "entry.77071893_month": date[1],
        "entry.77071893_day": date[2],
        # Hour
        "entry.855769839": hour[0] + 'h',
        # Checkbox 
        "entry.819260047": ["Cà phê", "Bể bơi"],
        # One choice
        "entry.1682233942": "Okay"
    }
    print(value, flush = True)
    return value

Submit form

Just use POST method in requests

def submit(url, data):
    try:
        requests.post(url, data = data)
        print("Submitted successfully!")
    except:
        print("Error!")

submit(url, fill_form())

Done!!!

Limitations

Please note that this script currently operates only with Google Forms that do not require user authentication.

googleform-autofill-and-submit's People

Contributors

tienthanh214 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

googleform-autofill-and-submit's Issues

Licence and code usage

Hi,

Can I use your code in my application ? I forked your repo and plan to keep the code open but since there's no licence here I find it better to ask directly.

Thanks

Email response slot can't find by from.py

I tried this awesome script to help me automate the Google form but it seems can't get the email response slot via from.py if the form holder requires the respondent's email. Does anyone know how to solve the issue?

Form có nhiều phần

Nếu cái form có nhiều phần khác nhau thì sao ông. Ví dụ t có 1 cái form gồm 4 phần:

  • p1: giới thiệu chủ đề (đọc rồi bấm next thôi)
  • p2: điền thông tin cá nhân
  • p3: điền khảo sát dạng lưới nhiều câu hỏi
  • p4: cảm ơn j đó (cũng đọc r bấm Gửi)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.