Skip to content

Instantly share code, notes, and snippets.

@vipulgupta2048
Last active March 21, 2020 07:08
Show Gist options
  • Select an option

  • Save vipulgupta2048/4aab4aa4edc94b09a3332fc24f8a242a to your computer and use it in GitHub Desktop.

Select an option

Save vipulgupta2048/4aab4aa4edc94b09a3332fc24f8a242a to your computer and use it in GitHub Desktop.
Automating Happiness Packets (for Acknowledgementations!) by vipulgupta2048
# Author: vipulgupta2048
# Date: 20/03/20
# Script to send bulk Happiness Packets (HP) to groups of people. With every loop, the script prefills information of sender, recipient and message in respective fields and repeats the process in a new tab. The result (https://imgur.com/a/kR2EP4j) is pre-filled tabs with ready to send content.
# Limits: I didn't automate the script to send the packet, because even though I want the content to be similar. Each HP that I send has something unique. Also, because HP limits 20 packets per email per 24 hours.
# License: Do whatever you want with it
# Libraries needed - Selenium, Chromedriver or Geckodriver
# Reference: https://pythonspot.com/category/selenium/ | https://selenium-python.readthedocs.io/installation.html
# Run the commands after unzipping the webdriver in the home directory
# sudo chmod +x /usr/bin/chromedriver
# sudo chown root:root /usr/bin/chromedriver
# sudo mv chromedriver /usr/bin/chromedriver
# pip install -U selenium
# At last, download the gist and run with python3 automating-happiness-packets.py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Chromedriver options for Selenium (Similar if you use Gecko)
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
# location of browser
options.binary_location = "/usr/bin/google-chrome"
# Webdriver location
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=options)
# Fetch URL of Happiness Packets Website
driver.get('https://www.happinesspackets.io/send/')
# Enter details
recipients_list = {'NAME OF SENDER':"EMAIL OF SENDER"}
counter = 0
for recipient_name, recipient_email in recipients_list.items():
message = "MESSAGE goes here!"
counter = counter + 1
# Adding Sender's name
driver.find_element_by_name("sender_name").send_keys("YOUR NAME GOES HERE")
# Adding Sender's email
driver.find_element_by_name("sender_email").send_keys("YOUR EMAIL GOES HERE")
# Adding Recipient's name
driver.find_element_by_name("recipient_name").send_keys(recipient_name)
# Adding Recipient's email
driver.find_element_by_name("recipient_email").send_keys(recipient_email)
# Hitting them checkboxes
driver.find_element_by_name("sender_named").click()
# Adding Happy message
driver.find_element_by_name("message").send_keys(message)
# Opens new tab in the same window
driver.execute_script("window.open('https://www.happinesspackets.io/send/');")
# Switches to new tab and repeats process
driver.switch_to.window(driver.window_handles[counter])
@vipulgupta2048
Copy link
Author

Author: vipulgupta2048
Date: 20/03/20

Objective

Script to send bulk Happiness Packets (HP) to groups of people. With every loop, the script prefills information of sender, recipient and message in respective fields and repeats the process in a new tab. The result (https://imgur.com/a/kR2EP4j) is pre-filled tabs with ready to send content.

Limits: I didn't automate the script to send the packet, because even though I want the content to be similar. Each HP that I send has something unique. Also, because HP limits 20 packets per email per 24 hours.
License: Do whatever you want with it
Libraries needed - Selenium, Chromedriver or Geckodriver
Reference: https://pythonspot.com/category/selenium/ | https://selenium-python.readthedocs.io/installation.html

Run the commands after unzipping the webdriver in the home directory

sudo chmod +x /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo mv chromedriver /usr/bin/chromedriver
pip install -U selenium

At last, download the gist and run with python3 automating-happiness-packets.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment