· 4 years ago · Dec 02, 2020, 12:50 AM
1from selenium import webdriver
2from faker import Factory
3import time
4import unidecode
5import random
6
7fake = Factory.create('pl_PL')
8
9option = webdriver.ChromeOptions()
10option.add_argument("-incognito")
11#option.add_argument("--headless")
12#option.add_argument("disable-gpu")
13
14orgs = [
15 'Młodzi dla Wolności',
16 'Młodzież Wszechpolska',
17 'Armia Boga',
18 'Katolickie Stowarzyszenie Lekarzy Polskich',
19 'Papieska Akademia Życia',
20 'Polska Federacja Ruchów Obrony Życia',
21 '40 Dni dla Życia',
22 'Fundacja Pro',
23 'Duchowa adopcja',
24 'Marsz dla Życia i Rodziny',
25 'Strona Życia',
26 'Forum Młodych PiS',
27 'Fundacja Życie i Rodzina',
28 'Polska 2050',
29 'Marsz Świętości Życia'
30]
31
32browser = webdriver.Chrome(executable_path='chromedriver', options=option)
33while True:
34 browser.delete_all_cookies()
35 browser.get('https://docs.google.com/forms/d/1hUxLMJxDSmVDVD1rP3dJ3jSaUKPKh2Du4PnGLvMd5_Q')
36
37 textboxes = browser.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
38 radiobuttons = browser.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
39 checkboxes = browser.find_elements_by_class_name("quantumWizTogglePapercheckboxInnerBox")
40 submitbutton = browser.find_elements_by_class_name("appsMaterialWizButtonPaperbuttonEl")
41
42 p = browser.current_window_handle
43
44 radiobuttons[0].click()
45 fn = fake.first_name()
46 ln = fake.last_name()
47 fnu = unidecode.unidecode(fn).replace(' ', '')
48 lnu = unidecode.unidecode(ln).replace(' ', '')
49 textboxes[0].send_keys(fn)
50 textboxes[1].send_keys(ln)
51 textboxes[2].send_keys(fake.phone_number())
52 textboxes[3].send_keys(fnu.lower() + '.' + lnu.lower() + '@gmail.com')
53 textboxes[4].send_keys('https://facebook.com/' + fnu.lower() + '.' + lnu.lower())
54
55 if random.randint(0,1) == 0:
56 org = fake.word().capitalize()
57 else:
58 org = orgs[random.randint(0, len(orgs) - 1)]
59
60 textboxes[5].send_keys(org)
61 submitbutton[1].click()
62 time.sleep(0.4)
63