def createAccount():
    browser= webdriver.Chrome("/usr/local/bin/chromedriver")
    browser.get("http://www.instagram.com")
    time.sleep(10) #time.sleep count can be changed depending on the Internet speed.
    
    #Generate User details
    email = account.generatingEmail()
    username = account.username()
    fullname = account.generatingName()
    password = '******'+username

    #Save to File in json Format
    data = {}  
    data['users'] = []  
    data['users'].append({  
        'email': email,
        'username': username,
        'fullname': fullname,
        'password': password
        })

    with open('data.txt', 'w') as outfile:  
        json.dump(data, outfile)

    #Fill the email value
    email_field = browser.find_element_by_name('emailOrPhone')
    email_field.send_keys(email)
    print('email : '+email)

    #Fill the fullname value
    fullname_field = browser.find_element_by_name('fullName')
    fullname_field.send_keys(fullname)
    print('account : '+fullname)

    #Fill username value
    username_field = browser.find_element_by_name('username')
    username_field.send_keys(username)
    print('username : '******'password')
    password_field.send_keys(password) #You can determine another password here.
    print('password : '******'//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/div[7]/div[1]/button')
    submit.click()
    time.sleep(8)
    print('Registering....')
Beispiel #2
0
from selenium.webdriver.common.by import By
import accountInfoGenerator as account

browser= webdriver.Chrome("chrome web driver path here")
browser.get("http://www.instagram.com")
time.sleep(8) #time.sleep count can be changed depending on the Internet speed.
name = account.username()

#Fill the email value
email_field = browser.find_element_by_name('emailOrPhone')
email_field.send_keys(account.generatingEmail())
print(account.generatingEmail())

#Fill the fullname value
fullname_field = browser.find_element_by_name('fullName')
fullname_field.send_keys(account.generatingName())
print(account.generatingName())
#Fill username value
username_field = browser.find_element_by_name('username')
username_field.send_keys(name)
print(name)
#Fill password value
password_field  = browser.find_element_by_name('password')
password_field.send_keys('aa12345bb12345cc'+name) #You can determine another password here.

submit = browser.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/div[6]/span/button')
submit.click()
time.sleep(8)

print('Registering....')
Beispiel #3
0
def code():
    # Fill the fullname value
    fullname_field = browser.find_element_by_name('fullName')
    fullname_field.send_keys(account.generatingName())
    print(account.generatingName())
    user_name = account.generatingName()
    user_name = user_name.replace(" ", "_")
    user_name_f = ""
    o = 0
    for i in user_name:
        if o < 14:
            # print(i)
            user_name_f += i
        o += 1

    # Fill username value
    username_field = browser.find_element_by_name('username')
    # username_field.send_keys(name)
    username_field.send_keys(user_name_f.lower())
    print(user_name_f.lower())
    # time.sleep(10)
    # Fill password value
    password_field = browser.find_element_by_name('password')
    password_field.send_keys('ammar0599')
    # if email_opt == 0:
    #     password_field.send_keys(pass_opt)  # You can determine another password here.
    # if email_opt != 0:
    #     password_field.send_keys(account.generatePassword())  # You can determine another password here.
    #     print(account.generatePassword())
    WebDriverWait(browser, 20).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "//*[@id='react-root']/section/main/div/div/div[1]/div/form/div[7]/div/button"
        ))).click()

    time.sleep(8)

    # Birthday verification
    browser.find_element_by_xpath(
        "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select"
    ).click()
    WebDriverWait(browser, 20).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select/option[4]"
        ))).click()

    browser.find_element_by_xpath(
        "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[2]/select"
    ).click()
    WebDriverWait(browser, 20).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[2]/select/option[10]"
        ))).click()

    browser.find_element_by_xpath(
        "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[3]/select"
    ).click()
    WebDriverWait(browser, 20).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[3]/select/option[27]"
        ))).click()

    WebDriverWait(browser, 20).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "//*[@id='react-root']/section/main/div/div/div[1]/div/div[6]/button"
        ))).click()
    time.sleep(3)
def insta():
    print("We are now using this proxy:" + randomproxy())

    while True:
        chrome_option = webdriver.ChromeOptions()
        #chrome_option.add_argument('--proxy-server=%s' % randomproxy())
        # #hrome_option.add_argument('--headless') ,service_args=['--verbose', '--log-path=/tmp/chromedriver.log']
        display = Display(visible=0, size=(1024, 768))
        display.start()
        browser = webdriver.Chrome("./chromedriver", options=chrome_option)
        action_chains = ActionChains(browser)

        ##checks if theres internet
        ###################################################################################################
        def has_connection(browser):
            try:
                browser.find_element_by_xpath(
                    '//span[@jsselect="heading" and @jsvalues=".innerHTML:msg"]'
                )
                return False
            except:
                return True

        browser.get("https://www.instagram.com/")
        #if no internet then restart progras
        if not has_connection(browser):
            print('No Internet connection, aborted!')
            browser.quit()
            os.execv(sys.executable, ['python'] + sys.argv)
        ##################################################################################################
        time.sleep(
            2
        )  #time.sleep count can be changed depending on the Internet speed.
        name = account.username()

        #Fill the email value
        email_field = browser.find_element_by_name('emailOrPhone')
        action_chains.move_to_element(email_field)
        email = random_surname() + '_' + account.generatingEmail()
        email_field.send_keys(email)
        time.sleep(2)
        print("We registered with email " + email)
        #Fill the fullname value
        fullname_field = browser.find_element_by_name('fullName')
        action_chains.move_to_element(fullname_field)
        fullname = account.generatingName()
        fullname_field.send_keys(fullname)
        time.sleep(2)
        print("We registered with name" + fullname)
        #Fill username value
        username_field = browser.find_element_by_name('username')
        name2 = (name + guess_number())
        action_chains.move_to_element(username_field)
        time.sleep(2)
        username_field.send_keys(name2)
        print("We registered using this username" + name2)
        #Fill password value
        password_field = browser.find_element_by_name('password')
        action_chains.move_to_element(password_field)
        time.sleep(2)
        password_field.send_keys(
            'aa12345bb12345cc' +
            name)  #You can determine another password here.
        ################################################################################################################################################
        #checks if submit is there and is clickable
        try:
            button = browser.find_element_by_xpath(
                '//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/div[7]/div/button'
            )
            if button.is_displayed() and button.is_enabled():
                print("Submit is there")
                action_chains.move_to_element(button)
                button.click()
        except NoSuchElementException:
            print('Error found in Submit! , aborted!')
            browser.quit()
            os.execv(sys.executable, ['python'] + sys.argv)
        ################################################################################################################################################
        has_error(browser)
        time.sleep(1)
        #checks if ARE YOU 18 is there and clicks it if not restarts
        try:
            el18 = browser.find_element_by_xpath(
                ("//div[@id='ageBucketSection']/fieldset/label/input"))
            if el18.is_displayed() and el18.is_enabled():
                print("18 bar is there")
                action_chains.move_to_element(el18)
                el18.click()
        except NoSuchElementException:
            print('Error found in 18bar! , aborted!')
            browser.quit()
            os.execv(sys.executable, ['python'] + sys.argv)
        ##################################################################################################################################################

        time.sleep(5)
        #checks if next is there and clicks it if not restarts and if yes saves credentials
        try:
            next = browser.find_element_by_xpath(
                '/html/body/div[3]/div/div[3]/div/button')
            if next.is_displayed() and next.is_enabled():
                print("Next bar is there and going to save now credentials")
                next.click()
                f = open('../instabut/examples/secret.txt', 'a')
                f.write(name2 + ':' + ('aa12345bb12345cc' + name2))
                f.write('\n')
                f.close()
                browser.close()
        except NoSuchElementException:
            print('Error found in next! , aborted!')
            browser.quit()
            os.execv(sys.executable, ['python'] + sys.argv)
        ##################################################################################################################################################
        time.sleep(10)