Exemple #1
0
def levelTwo():
    rw = RandomWord(max_word_size=10,
                    constant_word_size=True,
                    special_chars=r"@#$%.*",
                    include_special_chars=True)
    return rw.generate()
    print(rw.generate())
Exemple #2
0
    async def ran_word(self, ctx):
        rw = RandomWord(max_word_size=15,
                        constant_word_size=True,
                        special_chars=r"@#$%.*",
                        include_special_chars=True)

        await ctx.send(rw.generate())
Exemple #3
0
def main_gen():
    ''' Creates main dict '''
    import pprint
    import random
    from RandomWordGenerator import RandomWord

    rw = RandomWord(max_word_size=5)
    for_model = rw.generate()
    res = str(int(random.random()))
    model = "shop_{}.book".format(for_model)
    result = {}
    val = [model, random.randrange(1, 50)]
    keys = ["model", "pk"]
    final = ','.join(('{},{}'.format(y, x) for y, x in (list(i for i in (zip(keys, val)))))).split(',')
    fld = {"field": ' '}
    for key, val in fld.items():
        collect = delegate(result, key)
        next(collect)
        for v in val:
            collect.send(v)
        collect.send(None)


    i = iter(final)
    book = dict(zip(i, i))
    book.update(result)

    while True:
        yield book
Exemple #4
0
def main_gen():
    ''' Creates main dict '''
    import pprint
    import random
    from RandomWordGenerator import RandomWord

    rw = RandomWord(max_word_size=5)
    for_model = rw.generate()
    res = str(int(random.random()))
    model = "shop_{}.book".format(for_model)
    result = {}
    for_result_dict = next(subgen())
    result.update(for_result_dict)
    val = [model, random.randrange(1, 50)]
    keys = ["model", "pk"]
    final = ','.join(('{},{}'.format(y, x) for y, x in (list(
        i for i in (zip(keys, val)))))).split(',')
    fld = {"field": result}

    i = iter(final)
    book = dict(zip(i, i))
    book.update(fld)

    while True:
        yield book
Exemple #5
0
def home():


	rw = RandomWord(max_word_size=10,
		                constant_word_size=True,
		                include_digits= True,
		                special_chars=r"$%.*",
		                include_special_chars=True)
	print(rw.generate())

	return render_template("random_app.html", data = rw.generate())
def genJobTitle():
    wrdCount = random.randint(1, 2)
    wrdSize = random.randint(8, 10)
    title = ""
    iteRatr = 0
    for i in range(wrdCount):
        title += RandomWord(max_word_size=wrdSize).generate()
        if iteRatr == 0 and wrdCount == 2:
            title += " "
        iteRatr = 1
    return title
Exemple #7
0
def generate(numOfWords, write=0):
    r = RandomWord()
    words = r.getList(numOfWords)
    copy = words
    if write == 1:
        bar = br.Bar('Generating Words', max=numOfWords)
        words = map(lambda x: x + '\n', words)
        with open("words.txt", "w") as f:
            for x in words:
                f.write(x)
                bar.next()
        bar.finish()
    return copy
Exemple #8
0
def generatePassword(numberTests, wordSize):

    baseDeDados = []

    rw = RandomWord(max_word_size=wordSize, constant_word_size=False)

    count = 0

    while True:
        if count == numberTests:
            return baseDeDados
            break
        else:
            palavra = rw.generate()
            palavra = palavra.upper()
            count += 1
            baseDeDados.append(palavra)


# print(generatePassword(200, 5))
Exemple #9
0
def subgen():
    ''' Creates a dict which will be nested to main dict as a value'''

    from RandomWordGenerator import RandomWord
    import random
    import datetime

    year = str(datetime.datetime.now() -
               datetime.timedelta(days=random.randrange(400, 1000)))[0:4]
    isbn_13 = '{}-{}-{}-{}-{}'.format(random.randrange(111, 999),
                                      random.randrange(1, 10),
                                      random.randrange(0, 99999),
                                      random.randrange(111, 999),
                                      random.randrange(1, 10))
    rw = RandomWord(max_word_size=5)
    book_name = rw.generate()
    res = str(int(random.random()))

    author = (((lambda x, y: x + y)(
        ("author_{}, ".format(random.randrange(101, 200))),
        ("author_{}".format(random.randrange(1, 100)))))).split(',')
    rating = random.randrange(1, 100)
    price = round(random.uniform(1111111.0, 999999.9), 2)
    discount = random.randrange(1, 50)
    val_for_nested_dict = [
        '{}_book'.format(book_name), year, (str(random.randrange(50, 1500))),
        isbn_13, rating, price, discount
    ]
    lst_for_nested_dict = [
        "title", "year", "pages", "isbn13", "rating", "price", "discount",
        "author"
    ]
    nested_dict = ','.join(('{},{}'.format(y, x) for y, x in (list(
        i
        for i in (zip(lst_for_nested_dict, val_for_nested_dict)))))).split(',')
    final = {"author": author}
    i = iter(nested_dict)
    ndict = dict(zip(i, i))
    ndict.update(final)
    while True:
        yield ndict
Exemple #10
0
def routerBulk(request):
    print("dfgdgf")
    rw = RandomWord(max_word_size=5)
    res = []
    val = {}
    for i in range(0, 3):

        tmp = str(rw.generate())
        val["sapid"] = tmp + str(i)
        val["hostname"] = tmp
        val["loopbackid"] = ".".join(
            map(str, (random.randint(0, 255) for _ in range(4))))
        val["mac_add"] = str(RandMac())
        ser = RouterDetailsSerializer(data=val)
        print(ser)
        if ser.is_valid():
            ser.save()
            print("****")
            res.append(val["loopbackid"])

    return Response(res)
    def test_random_storage(self):
        random_words = RandomWord(3)
        storage = RequestsStorage()
        storage_ok = RequestsStorageWorking()

        urls = list()
        methods = ['get', 'post']
        commands = list()

        def new_random_url():
            scheme = ['http', 'https', 'ftp']

            url = '{}://{}.{}'.format(choice(scheme), random_words.generate(),
                                      random_words.generate())

            return url if url not in urls else new_random_url()

        for _ in range(90000):
            method = choice(methods)

            if method == 'get':
                should_request_existing = choice([True, False])
                url = choice(urls) if should_request_existing and len(
                    urls) > 0 else new_random_url()
                commands.append('get {}'.format(url))

                self.assertEqual(storage_ok.get(url),
                                 storage.get(url),
                                 msg='\n'.join(commands))
            else:
                url = new_random_url()
                content = ' '.join(random_words.getList(num_of_words=3))

                urls.append(url)
                commands.append('post {} {}'.format(url, content))

                self.assertEqual(storage_ok.post(url, content),
                                 storage.post(url, content),
                                 msg='\n'.join(commands))
Exemple #12
0
from RandomWordGenerator import RandomWord
import time, random

while True:
    rw = RandomWord(max_word_size=100)
    x = rw.generate().upper()
    print(x)
    time.sleep(0.3)
    if 'FD' in x:
        break
Exemple #13
0
def create_account(driver, x_i, y_i):

    print(Fore.CYAN+"Creating Account...........", Fore.WHITE)
    print()
    word = RandomWord(max_word_size = 7).generate()+str(random.randint(0, 9))+str(random.randint(0, 9))
    word = word.lower()
    driver.get("https://mail.protonmail.com/create/new?language=en")
    
    randpwd = random_pwd()
    time.sleep(1)
    WebDriverWait(driver, 60).until(EC.visibility_of_element_located(
        (By.TAG_NAME, 'iframe')))
    time.sleep(.5)
    
    driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))
    WebDriverWait(driver, 60).until(EC.presence_of_element_located(
        (By.ID, 'username'))).click
    time.sleep(.5)
    username = WebDriverWait(driver, 60).until(EC.presence_of_element_located(
        (By.ID, 'username')))

    for i in word:
        username.send_keys(i)
        time.sleep(.1)

    driver.switch_to.default_content()

    print(Fore.CYAN+"Please wait\n\n", Fore.WHITE)

    password = WebDriverWait(driver, 60).until(
        EC.element_to_be_clickable((By.ID, 'password')))

    for i in randpwd:
        password.send_keys(i)
        time.sleep(.1)
    time.sleep(.5)

    print(Fore.CYAN+"Please wait\n\n", Fore.WHITE)
    input_value(driver, '//*[@id = "passwordc"]', randpwd)
    time.sleep(.5)
    driver.switch_to.frame(driver.find_element_by_class_name("bottom"))
    human_move(driver, '//*[@id = "app"]/div/footer/button', x_i, y_i)
    driver.switch_to.default_content()
    time.sleep(1)

    check_error = True
    while check_error == True:
        try:
            WebDriverWait(driver, 4).until(
                EC.presence_of_element_located((By.CSS_SELECTOR, 'div[class = "modal-footer"]')))
            check_error = False
        except:
            print(Fore.RED+"\nUsername error\n", Fore.WHITE)
            print(Fore.LIGHTGREEN_EX+"Solving", Fore.WHITE)
            randuser = random_user()

            driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))
            while username.get_attribute('value') != '':
                username.send_keys(Keys.BACKSPACE)

            randuser = random_user() 

            for i in randuser:
                username.send_keys(i)
                time.sleep(.1)

            driver.switch_to.default_content()
            time.sleep(.5)
            driver.switch_to.frame(driver.find_element_by_class_name("bottom"))
            
            human_move(driver, '//*[@id = "app"]/div/footer/button', x_i, y_i)

            driver.switch_to.default_content()

            print(Fore.LIGHTGREEN_EX+"Maybe solved", Fore.WHITE)
            check_error = True
            time.sleep(.3)

    human_move(driver, '//*[@id = "confirmModalBtn"]', x_i, y_i)
    time.sleep(1)

    try:
        human_move(driver, '//*[@id="verification-panel"]/div[3]/label/div', x_i, y_i)
        human_move(driver, '//*[@id="verification-panel"]/div[2]/label/div', x_i, y_i)
    except:
        print(Fore.RED+"Looks like YOU have abused the bot!! Try Again later", Fore.WHITE)
        input("Press enter/return key to exit.")
        driver.close()
        return

    human_move(driver, '//*[@id="emailVerification"]',x_i,y_i)

    domain = ['boximail.com']
    email = word + "@" + random.choice(domain)
    input_value(driver, '//*[@id ="emailVerification"]', email)
    human_move(driver, '//*[@id="verification-panel"]/form[1]/div[1]/div[2]/button', x_i, y_i)

    check_error = True
    while check_error:  #check if domain is blocked
        try:
            time.sleep(1)
            driver.find_element_by_xpath('//*[@id="signup"]/div[4]')
            email = word + "@" + random.choice(domain)
            driver.find_element_by_xpath('//*[@id ="emailVerification"]').clear()
            input_value(driver, '//*[@id ="emailVerification"]', email)       
            human_move(driver, '//*[@id="verification-panel"]/form[1]/div[1]/div[2]/button', x_i, y_i)
            time.sleep(1)
        except:
            check_error = False
    while True:
        try:
            uid = requests.get(f"https://getnada.com/api/v1/inboxes/{email}").json()
            uid = uid["msgs"][0]["uid"]
            break
        except:
            time.sleep(1)
            pass
    html = requests.get(f"https://getnada.com/api/v1/messages/html/{uid}").content
    soup = bs(html,"html5lib")
    code = soup.find("code").text
    
    human_move(driver, '//*[@id="codeValue"]',x_i, y_i)
    code_input = WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type = "text"]')))
    for i in code:
        code_input.send_keys(i)
        time.sleep(.1)

    human_move(driver, '//*[@id="verification-panel"]/p[3]/button', x_i, y_i) # Complete setup btn
    time.sleep(1)

    human_move(driver, '//*[@id="confirmModalBtn"]',x_i,y_i)

    for _ in range(0, 3):
        human_move(driver, '//*[@id="pm_wizard"]/div/div[5]/button[1]',x_i,y_i)
        time.sleep(.5)
    human_move(driver, '//*[@id="pm_wizard"]/div/div[5]/button[2]',x_i,y_i)

    print(Fore.GREEN+"\nAccount Details.\n", Fore.WHITE)

    username = "******" + word
    password = "******" + randpwd
    with open("Accounts.txt", 'a') as f:
        f.write(datetime.now().strftime("%Y-%m-%d %H:%M")+"\n")
        f.write(username+"\n")
        f.write(password+"\n")
        f.write("-------------------------------\n")
    print(username)
    print(password)

    return
Exemple #14
0
from time import sleep
import names
from RandomWordGenerator import RandomWord
import requests
import json
import random
import pytest


rw = RandomWord()
#Datos API
base='http://*****:*****@pytest.mark.parametrize("userid, name", [(1,"Luke"),(3,"David")])
def test_employee_by_id(supply_url,userid,name):
    response = requests.get(supply_url+'employees/'+str(userid))
    response_data = response.json()
    assert response.status_code == 200
    assert response_data['id'] == userid
    assert response_data['name'] == name

def test_nf_employee_by_id(supply_url, id = 0):
    response = requests.get(supply_url+'employees/'+str(id))
Exemple #15
0
@author: andrea.baccolini
"""

import random
from random_word import RandomWords
from RandomWordGenerator import RandomWord

r = RandomWords()
r1 = RandomWords()
# r3 = r.get_random_words()
#r2.get_random_word()

# Creating a random word object
rw = RandomWord(constant_word_size=True,
                include_digits=False,
                special_chars=r"@_!#$%^&*()<>?/\|}{~:",
                include_special_chars=False)
print(r1)
print(r)
# print(r3)

nouns = ("puppy", "car", "rabbit", "girl", "monkey")
verbs = ("runs", "hits", "jumps", "drives", "barfs")
adv = ("crazily.", "dutifully.", "foolishly.", "merrily.", "occasionally.")
adj = ("adorable", "clueless", "dirty", "odd", "stupid")

num1 = random.randrange(0, 5)
num2 = random.randrange(0, 5)
num3 = random.randrange(0, 5)
num4 = random.randrange(0, 5)
def test1():
    rw = RandomWord(max_word_size=-15, constant_word_size=True)
    assert rw.generate() is None
def test6():
    rw = RandomWord(max_word_size=1000, constant_word_size=False)
    assert len(rw.getList(num_of_words=1000)) == 1000
def test8():
    rw = RandomWord(max_word_size=1000, constant_word_size=False)
    assert rw.getList(num_of_words=-15) is None
 def generate_word(self, number):
     return RandomWord(max_word_size=number).generate()
Exemple #20
0
def generate_random_letter():
    print('''Choose the difficulty level 
    1.Easy
    2.Normal
    3.Hard
    4.Extreme''')
    user_input = int(input('Enter your choice here:- '))

    if user_input == 1:
        word_lenth = 2
    elif user_input == 2:
        word_lenth = 3
    elif user_input == 3:
        word_lenth = 4
    elif user_input == 4:
        word_lenth = 5
    Random_letters = RandomWord(max_word_size=word_lenth)
    letters = Random_letters.generate()

    # The instructions for the user.
    Instructions = f'''\nComputer has choosen {word_lenth} letters. 
Guess these {word_lenth} in 3 chances for each letter.\n'''
    print(Instructions)
    counter = 0  # This variable will count the number of chances of user to guess the letter.

    # This while statement will be keep running until the counter is less than 3.
    while counter < 3:

        # This if statement will run when user_input will be equal to 1.
        if word_lenth == 2:
            user_guess_1 = input('Guess both letters:- ')
            if user_guess_1 == letters:
                print('The Letters are correct.\nWell Played!!')
            elif user_guess_1 != letters:
                print("The letters are wrong.")
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 2.
        elif word_lenth == 3:
            user_guess_2 = input('Guess the 3 random letters:- ')
            if user_guess_2 == letters:
                print('The letters are correct.\nWell Played!!')
            elif user_guess_2 != letters:
                print('The letters are wrong.')
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 3.
        elif word_lenth == 4:
            user_guess_3 = input('Guess the 4 random letters:- ')
            if user_guess_3 == letters:
                print('The letters are correct.\nWell Played!!')
            elif user_guess_3 != letters:
                print('The letters are wrong.')
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 4.
        elif word_lenth == 5:
            user_guess_4 = input('Guess the 5 random letters:- ')
            if user_guess_4 == letters:
                print('The letters are correct.\nWell PLayed!!')
            elif user_guess_4 != letters:
                print('The letters are wrong.')
                counter = counter + 1

    # This else statement will run when the counter will be equal to 3.
    else:
        print("\nYour all 3 chances are over.\nBetter Luck Next Time!!")
        print(f'The correct letters are "{letters}"')
import csv
import json
from faker import Faker
import random
from RandomWordGenerator import RandomWord

nums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
phones = []
for i in range(1000000):
    phones.append('+7' + ''.join(random.sample(nums, 10)))

rw1 = RandomWord(constant_word_size=False)
rw2 = RandomWord(max_word_size=5, constant_word_size=False)   
mails = []
for i in range(1000000):
    mails.append(rw1.generate() + '@' + rw2.generate() + '.com')

fake = Faker()
destinations_date = [['name', 'contact', 'offered_products']]
for i in range(1, 1000001):
    contact = {
        'phone': phones[i - 1],
        'email': mails[i - 1],
        'address':fake.address()
    }
    offered_products = [random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000)]
    destinations_date.append([fake.name(), json.dumps(contact), offered_products])

myFile = open('destinations_date.csv', 'w')
with myFile:
    writer = csv.writer(myFile)
Exemple #22
0
def levelOne():
    rw = RandomWord(max_word_size=8, constant_word_size=False)
    return rw.generate()
    print(rw.generate())
def test4():
    rw = RandomWord(max_word_size=1000, constant_word_size=True)
    assert len(rw.getList(num_of_words=12)) == 12
Exemple #24
0
def gen():
    word = RandomWord(max_word_size=7).generate() + str(random.randint(
        0, 9)) + str(random.randint(0, 9))
    word = word.lower()
    email = word + "@zetmail.com"

    headers = {
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'en-US,en;q=0.9',
        'Connection': 'keep-alive',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'DNT': '1',
        'Host': 'account.cosmote.gr',
        'Origin': 'https://account.cosmote.gr',
        'Referer':
        'https://account.cosmote.gr/register?nakedRegister&chid=foodboxweb&alt-theme=third-party',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'same-origin',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Edg/85.0.564.63',
        'X-Requested-With': 'XMLHttpRequest',
    }

    data = {
        "username-autofill": "",
        "password-autofill": "",
        "csm-email": email,
        "csm-name": "fVictor",
        "csm-surname": "fbrown",
        "csm-password": "******",
        "csm-recovery-asset": "*****@*****.**",
        "csm-mail": "*****@*****.**"
    }

    s = requests.session()
    s.get(
        "https://account.cosmote.gr/el/register?nakedRegister&chid=foodboxweb&alt-theme=third-party"
    )
    cosmote = "https://account.cosmote.gr/register?p_p_id=Cosmoteid_INSTANCE_ElwamDfwl07C&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=registerUserNaked&p_p_cacheability=cacheLevelPage"
    s.post(url=cosmote, data=data, headers=headers)

    sleep(1)

    token = []
    while token == []:
        token = s.get(f"https://getnada.com/api/v1/inboxes/{email}").json()
        token = token["msgs"]
    token = token[0]["uid"]

    html = s.get(f"https://getnada.com/api/v1/messages/html/{token}").content
    print(html)
    soup = bs(html, "html5lib")
    url = soup.find("a", attrs={'id': 'emailSubmitImageUrl'})['href']

    s.get(url)
    data = {
        "IDToken1":
        f"{email}",
        "IDToken2":
        "TECHTANIC#8090",
        "realm":
        "hub",
        "goto":
        "https://account.cosmote.gr/user-login",
        "gotoOnFail":
        "https://account.cosmote.gr/user-login?p_p_id=CosmoteLogin_INSTANCE_XQ2b6cwTiH8w&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&_CosmoteLogin_INSTANCE_XQ2b6cwTiH8w_loginError=true&channelLoginError=true&chid=ACCOUNTS&"
    }
    s.post("https://idmextsso.ote.gr/opensso/OTECloudLogin", data=data)
    #verify
    s.get("https://box.gr/")

    data = {
        "IDToken1":
        f"{email}",
        "IDToken2":
        "TECHTANIC#8090",
        "realm":
        "hub",
        "goto":
        "https%3A%2F%2Fidmextsso.cosmote.gr%2Fauth%2Frealms%2Fhub%2Fprotocol%2Fopenid-connect%2Fauth%3Fresponse_type%3Dcode%26scope%3Dopenid%26client_id%3Dboxweb%26redirect_uri%3Dhttps%3A%2F%2Fbox.gr%2Flogin",
        "gotoOnFail":
        "https://account.cosmote.gr/el/modalloginextended?p_p_id=CosmoteModalLoginExtended&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&_CosmoteModalLoginExtended_fullPageRedirect=true&_CosmoteModalLoginExtended_loginError=true"
    }
    headers = {
        "Accept":
        "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "Accept-Encoding":
        "gzip, deflate, br",
        "Accept-Language":
        "en-US,en;q=0.9",
        "Cache-Control":
        "max-age=0",
        "Connection":
        "keep-alive",
        "Content-Type":
        "application/x-www-form-urlencoded",
        "DNT":
        "1",
        "Host":
        "idmextsso.ote.gr",
        "Origin":
        "https://box.gr",
        "Referer":
        "https://box.gr/",
        "Sec-Fetch-Dest":
        "document",
        "Sec-Fetch-Mode":
        "navigate",
        "Sec-Fetch-Site":
        "cross-site",
        "Sec-Fetch-User":
        "******",
        "Upgrade-Insecure-Requests":
        "1",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Edg/85.0.564.70"
    }
    s.post("https://idmextsso.ote.gr/opensso/OTECloudLogin",
           data=data,
           headers=headers)
    ###
    r = s.get(
        "https://idmextsso.ote.gr/opensso/OTECloudLogin?target=https%3A%2F%2Fidmextsso.cosmote.gr%2Fauth%2Frealms%2Fhub%2Fprotocol%2Fopenid-connect%2Fauth%3Fresponse_type%3Dcode%26scope%3Dopenid%26client_id%3Dboxweb%26redirect_uri%3Dhttps%3A%2F%2Fbox.gr%2Flogin&realm=hub&stage=1"
    )

    #data = {"address":[{"type":"Σπίτι","latitude":"38.04623159999999","longitude":"23.8183371","city":"Μαρούσι","streetNo":"75","street":"Μεσογείων","region":"Περιφερειακή ενότητα Βορείου Τομέα Αθηνών","postalCode":"15126","floor":"2","nameAtBell":"γιαννης","comments":"null","firstName":"fVictor","lastName":"fbrown"}]}

    return email
def test3():
    rw = RandomWord(max_word_size=1000000, constant_word_size=True)
    assert len(rw.generate()) == 1000000
from solution import Reader
from RandomWordGenerator import RandomWord
"""
dask-worker tcp://192.168.6.40:8786 --nprocs 3 --memory-limit 3GB
"""

rw = RandomWord(
    max_word_size=10,
    constant_word_size=True,
    include_digits=False,
    special_chars="",  #r"@_!#$%^&*()<>?/\|}{~:",
    include_special_chars=False)
rw_b = RandomWord(max_word_size=15,
                  constant_word_size=True,
                  include_digits=True,
                  special_chars=r"@_!#$%^&*()<>?/\|}{~:",
                  include_special_chars=True)

import csv
import random

size = 1000
o_ids = list(range(size + 1))


def write_order():
    global o_ids, size
    c_ids = [rw.generate() for i in range(size)]
    with open('order_test.csv', 'w', newline='') as ff:
        writer = csv.writer(ff)
        writer.writerow(['order_id', 'customer_id'])
Exemple #27
0
def generateW():
    r = RandomWord()
    return r.generate()
def test9():
    rw = RandomWord(max_word_size=20,
                    constant_word_size=True,
                    special_chars="@^#\\\23",
                    include_special_chars=True)
    assert len(rw.getList(12)) == 12
Exemple #29
0
    def generate_random_documents(self, random_type=str, size=10):
        """
        Generate random documents to MongoDB.

        Args:
        -----
        random_type: Choose random data type. Has three type: int, float and str.
        
        size: Generate specified amount documents.
        """

        # Define constant.
        logging.info("Initializing random data constant variable...")
        if random_type == str:
            rand_account = RandomWord(max_word_size=12,
                                      constant_word_size=False,
                                      include_digits=True)
            rand_passwd = RandomWord(max_word_size=20,
                                     constant_word_size=False,
                                     include_digits=True,
                                     include_special_chars=True)
        elif random_type == int:
            computer_brands = [
                "ASUS", "Acer", "MSI", "Lenovo", "Microsoft", "Mac"
            ]
            countrys = ["America", "China", "Taiwan", "Japan", "Korea"]
        elif random_type == float:
            names = ["michael", "peter", "allen", "kevin", "jack"]
        else:
            logging.warning(
                "random_type data type error ! only str、int and float type.",
                exc_info=True)
            raise TypeError

        # Insert data to MongoDB.
        logging.info("Inserting {} type random data...".format(random_type))
        for i in range(size):
            if random_type == str:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                account = rand_account.generate()
                password = rand_passwd.generate()
                account_length = len(account)
                password_length = len(password)

                logging.debug(
                    self.collection.insert_one({
                        "account": account + '@gmail.com',
                        "password": password,
                        "account_length": account_length,
                        "password_length": password_length,
                        "create_time": create_time
                    }))
            elif random_type == int:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                year = randint(1980, 2021)
                country = countrys[randint(0, len(countrys) - 1)]
                computer_brand = computer_brands[randint(
                    0,
                    len(computer_brands) - 1)]
                notebook_sales = randint(100000, 99999999)
                pc_sales = randint(100000, 99999999)

                logging.debug(
                    self.collection.insert_one({
                        "year": year,
                        "country": country,
                        "computer_brand": computer_brand,
                        "notebook_sales": notebook_sales,
                        "pc_sales": pc_sales,
                        "create_time": create_time
                    }))
            elif random_type == float:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                name = names[randint(0, len(names) - 1)]
                height = randint(150, 220) + round(random(), 2)
                weight = randint(30, 100) + round(random(), 2)
                logging.debug(
                    self.collection.insert_one({
                        "name": name,
                        "height": height,
                        "weight": weight,
                        "create_time": create_time
                    }))

        logging.info("Insertd {} doduments successfully !".format(size))
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from random import *
import time
from RandomWordGenerator import RandomWord

rw = RandomWord(max_word_size=5, constant_word_size=False)
lst = rw.getList(num_of_words=50)
# print(lst)
# Should match with the current version of the Web browser
driver = webdriver.Chrome(executable_path=r'C:/chromedriver/chromedriver.exe')

driver.get("https://web.whatsapp.com/")

input("Please Scan QR CODE and press any key to continue: ")
name = input("Enter the Name to whom you want to send the message: ").title()
user = driver.find_element_by_css_selector(f'span[title="{name}"]')
user.click()
# may change inspect->select space -> right click -> copy ->xpath
test_input = driver.find_element_by_xpath("/html/body/div/div[1]/div[1]/div[4]/div[1]/footer/div[1]/div[2]/div/div[2]")
# time.sleep(10)
total_msg = int(input("Enter the Number of messages you want to send: "))
test_input.send_keys("Hello, This is message by raja")
test_input.send_keys(Keys.RETURN)
test_input.send_keys(f"You will be shortly receiving {total_msg} random messages.")
test_input.send_keys(Keys.RETURN)
time.sleep(5)
for i in range(total_msg):
    test_input.send_keys(choice(lst))
    test_input.send_keys(Keys.RETURN)