DEV Community

Cover image for Sign-up Form Automation with Python
1Blademaster
1Blademaster

Posted on

Sign-up Form Automation with Python

Today I will help you automate sign-up form automation with Python and Selenium by using a quick script which I wrote previously. This script will allow you to generate random data, fetch burner emails and use proxies to bypass IP blocks as well as allowing you to manually sign bot captures.

First things first

Firstly, make sure you have python 3.7 or above installed, once that's done you can clone this Github repo into your working directory.

You can then use pip install -r requirements.txt to install all the necessary requirements for the script.

Next make sure you have geckodriver.exe in your path or in the same directory as the account_creator.py file. This is the Firefox browser which selenium uses to control and automate. You can download it from here.

Next, creating a new python script

This is the script which we will execute to run the sign-up automation. Go ahead and make a new python file and start by adding the following line of code:

from account_creator import AccountCreator
Enter fullscreen mode Exit fullscreen mode

This will import the AccountCreator class into your script, you need to make sure this file is in the same directory as account_creator.py.

Underneath that add the following lines of Python:

signup_site = input('Enter the site you want to create an account for: ')

ac = AccountCreator(url=signup_site)
ac.enterData()

ac.close()
Enter fullscreen mode Exit fullscreen mode

These lines will capture a website url from a user input and then initilise the AccountCreator class with the url being passed in as an argument. The enterData method will then be called; this will create bogus data, as well as making a new window to get a burner email address from 10minutemail. This window will remain open until the close method is called, this is so that the inbox can easily be accessed. The enterData method will then try it's best to enter the data generated into the webform. Calling the close method closes all windows.

Extra stuffs

If you wanted to run the script with a proxy then you can use the http-request-randomizer library by installing it via pip install http-request-randomizer. Then simply copy the following code into a file and run it!

# This is a simple script which fetches a proxy and uses it to access a website

from account_creator import AccountCreator
from http_request_randomizer.requests.proxy.requestProxy import RequestProxy

if __name__ == '__main__':
    signup_site = input('Enter the site you want to create an account for: ')

    req_proxy = RequestProxy()
    proxies = req_proxy.get_proxy_list()
    proxies = [proxy for proxy in req_proxy.get_proxy_list() if proxy.country == 'United Kingdom'] # Get a list of proxies from the United Kingdom
    proxyStr = proxies[0].get_address() # Get the string for the proxy in the format IP:PORT

    ac = AccountCreator(proxyStr=proxyStr, url=signup_site)

    ac.enterData()

    ac.close()
Enter fullscreen mode Exit fullscreen mode

This script will get a list of free proxies to use and create browser windows using those proxies.

Links

Github repo: https://github.com/1Blademaster/account-creator
proxy module: https://pypi.org/project/http-request-randomizer/
geckodriver: https://github.com/mozilla/geckodriver/releases

Final notes

The names.txt file supplied contains a list of 200 random first and last names, this can be edited to suit your use case if needed.

All data generated will also be saved in an accounts.txt file so those credentials can be accessed at a later date.

This is my first post, and hopefully not my last, so any advice is greatly appreciated and thank you for reading 💖!

Top comments (0)