def instagram_login(self):
        """
        Handles login to instagram and returns the webdriver for use downstream
        """

        webdriver = self.webdriver
        sleep(2)
        webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
        sleep(3)

        try:
            allow_cookies = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.bIiDR')
            allow_cookies.click()
        except:
            pass
        sleep(3)

        username = webdriver.find_element_by_name('username')
        username.send_keys(self.username)
        password = webdriver.find_element_by_name('password')
        password.send_keys(self.password)

        button_login = webdriver.find_element_by_xpath('//*[@id="loginForm"]/div/div[3]/button/div')
        button_login.click()
        sleep(3)

        return webdriver
Exemplo n.º 2
0
def instaLogin():
    print("WELCOME TO InstaDownloader by KSHITIJ")
    print("Navigating to Instagram Login Page")
    webdriver.get(
        "https://www.instagram.com/accounts/login/?source=auth_switcher")
    sleep(2)
    username = webdriver.find_element_by_name("username")
    print("Entering Username")
    username.click()
    username.send_keys(InstaUsername)
    password = webdriver.find_element_by_name("password")
    print("Entering Password")
    password.click()
    password.send_keys(InstaPassword)
    sleep(2)
    loginButton = webdriver.find_element_by_css_selector(
        "#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child(4) > button > div"
    )
    sleep(1)
    loginButton.click()
    print("Logging in . . . ")

    sleep(2)
    if (len(webdriver.find_elements_by_class_name('eiCW-')) > 0):
        print("Incorrect Username or Password")
        exit()
Exemplo n.º 3
0
def auto_login(webdriver, login_username, login_password):
    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher'
    )  # Access Instagram login page
    sleep(3)

    # Navigate login infor box
    username = webdriver.find_element_by_name('username')
    username.send_keys('')
    username.send_keys(login_username)
    password = webdriver.find_element_by_name('password')
    password.send_keys('')
    password.send_keys(login_password)

    # Click log-in
    button_login = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child(4) > button > div'
    )
    button_login.click()
    sleep(3)

    # Skip pop-up dialog
    # Comment these lines out, if you don't get a pop up asking about notifications
    notnow = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > div > div > section > div > button'
    )
    notnow.click()
    sleep(3)
    notnow2 = webdriver.find_element_by_css_selector(
        'body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm'
    )
    notnow2.click()
    sleep(3)
Exemplo n.º 4
0
def login_selenium():
    '''initiates a chrome_driver window and logs into account'''

    chromedriver_path = (
        '/Users/Beto/galvanize/Instagram-API-python/InstagramAPI/chromedriver')
    webdriver = webdriver.Chrome(executable_path=chromedriver_path)
    sleep(2)
    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher')

    username = webdriver.find_element_by_name('username')
    username.send_keys('sf_clout')
    password = webdriver.find_element_by_name('password')
    password.send_keys('20190101')
    sleep(10)

    button_login = webdriver.find_element_by_xpath(
        '//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button/div'
    )
    button_login.click()
    sleep(5)

    notnow = webdriver.find_element_by_css_selector(
        'body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
    notnow.click()
Exemplo n.º 5
0
def main():
    items = []

    #Log in
    webdriver.get(MAIN_PAGE_URL)
    webdriver.find_element_by_id(
        'ctl00_ContentPlaceHolder1_Username').send_keys(
            credentials['username'])
    webdriver.find_element_by_id(
        'ctl00_ContentPlaceHolder1_Password').send_keys(
            credentials['password'])
    webdriver.find_element_by_name('ctl00$ContentPlaceHolder1$ctl04').click()

    #Set items to show = 100
    webdriver.find_element_by_xpath(
        "//select[@name='ctl00$ContentPlaceHolder1$GridView1$ctl13$ctl11']/option[text()='100']"
    ).click()
    #Getting number of pages
    page_number = len(
        webdriver.find_elements_by_xpath(
            "//tr[@class='grid-pager']//table//tr/td[not(@class)]"))
    page_href_script = "__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Page$%s')"

    #Extracting each page on the website
    for i in range(page_number):
        i += 1
        if i != 1:
            webdriver.execute_script(page_href_script % i)
            # Wait for redirecting
            time.sleep(10)
        items += extract()

    #Insert into database all extracted items (rigs)
    insert_into_database(items)
Exemplo n.º 6
0
def login(webdriver):
    # Open the instagram login page
    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher')
    # sleep for 3 seconds to prevent issues with the server
    time.sleep(3)
    # Find username and password fields and set their input using our constants
    username = webdriver.find_element_by_name('username')
    username.send_keys('*****@*****.**')
    password = webdriver.find_element_by_name('password')
    password.send_keys('Aida72584')
    # Get the login button
    try:
        button_login = webdriver.find_element_by_xpath(
            '//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button'
        )
    except:
        button_login = webdriver.find_element_by_xpath(
            '//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[6]/button/div'
        )
    # sleep again
    time.sleep(2)
    # click login
    button_login.click()
    time.sleep(3)
    # In case you get a popup after logging in, press not now.
    # If not, then just return
    try:
        notnow = webdriver.find_element_by_css_selector(
            'body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm'
        )
        notnow.click()
    except:
        return
Exemplo n.º 7
0
def insta():
    import selenium
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    USERNAME = str(input("Enetr your user name:"))
    PASSWORD = str(input("Enter Your Password:"))

    chromedriver_path = 'C:/chromedriver.exe'

    webdriver = webdriver.Chrome(executable_path=chromedriver_path)

    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher')
    sleep(5)

    username = webdriver.find_element_by_name('username')
    username.send_keys(USERNAME)
    password = webdriver.find_element_by_name('password')
    password.send_keys(PASSWORD)

    button_login = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child(4) > button > div'
    )
    button_login.click()
    sleep(6)
    not_now = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > div > div > div > button')
    not_now.click()
    sleep(6)
    notnow = webdriver.find_element_by_css_selector(
        'body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm'
    )
    notnow.click()

    def inbox():
        button_inbox = webdriver.find_element_by_css_selector(
            '#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.ctQZg > div > div:nth-child(2) > a > svg'
        )
        button_inbox.click()
        sleep(10)
        button_home = webdriver.find_element_by_css_selector(
            '#react-root > section > div > div._lz6s.Hz2lF > div > div.ctQZg > div > div:nth-child(1) > div > a > svg'
        )
        button_home.click()

    inbox()
    sleep(10)

    def activity():
        button_activity = webdriver.find_element_by_css_selector(
            '#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.ctQZg > div > div:nth-child(4) > a > svg'
        )
        button_activity.click()
        sleep(2)

    activity()

    webdriver.quit()
Exemplo n.º 8
0
 def runLogin(self, webdriver, account):
     webdriver.get('https://www.%s.com/accounts/login' %
                   (str.lower(account.accountType)))
     sleep(2)
     username = webdriver.find_element_by_name(self.username_input)
     username.send_keys(account.email)
     password = webdriver.find_element_by_name(self.password_input)
     password.send_keys(account.password)
     sleep(2)
     password.send_keys(Keys.RETURN)
Exemplo n.º 9
0
 def auth_with_data(self, webdriver, login, pswd):
     self.login = login
     self.pswd = pswd
     webdriver.get('https://passport.yandex.ru/auth')
     wait_for_element = WebDriverWait(webdriver, TIMEOUT).until(
         EC.element_to_be_clickable(
             (By.XPATH, '//*[@id="passp-field-login"]')))
     webdriver.find_element_by_xpath(
         '//*[@id="passp-field-login"]').send_keys(self.login + Keys.RETURN)
     wait_for_element = WebDriverWait(webdriver, TIMEOUT).until(
         EC.element_to_be_clickable((By.NAME, 'passwd')))
     webdriver.find_element_by_name('passwd').send_keys(self.pswd +
                                                        Keys.RETURN)
def initNJUJw(user, pwd):
    userInput = webdriver.find_element_by_name('userName')
    pwdInput = webdriver.find_element_by_name('password')
    userInput.send_keys(user)
    pwdInput.send_keys(pwd)
    sub = webdriver.find_element_by_class_name('Btn')
    sub.click()
    check = 'UserInfo'
    try:
        webdriver.find_element_by_id(check)
    except Exception, e:
        raise e
        return False
Exemplo n.º 11
0
def logIn(webdriver, login, password):
	email_el = webdriver.find_element_by_name("email")
	pass_el =  webdriver.find_element_by_name("pass")
	email_el.send_keys(login)
	pass_el.send_keys(password.decode("utf-8"))
	webdriver.find_element_by_xpath("//form[@id='login_form']//input[@type='submit']").click()
	current_url = webdriver.current_url
	print "url: " + current_url
	if "login.php" in current_url:
		print "Wrong login and/or password"
		return 0
	else:
		print "Succesfully logged in"
		return 1
Exemplo n.º 12
0
def LoggingIn(user, passs):
    username = webdriver.find_element_by_name('username')
    username.send_keys(user)

    password = webdriver.find_element_by_name('password')
    password.send_keys(passs)

    sleep(3)

    login_form = webdriver.find_element_by_xpath(
        '//*[@id= "react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button/div'
    )
    login_form.click()
    sleep(4)
Exemplo n.º 13
0
 def __set__(self, instance, value):
     """设置文本到元素中"""
     driver = object.driver
     driver.find_element_by_name()
     WebDriverWait(driver, 100).until(
         lambda driver: webdriver.find_element_by_name(self.locator))
     driver.find_element_by_name(self.locator).send_keys(value)
Exemplo n.º 14
0
def LoggingIn (user, passs):
    username = webdriver.find_element_by_name('username')
    username.send_keys(user)

    password = webdriver.find_element_by_name('password')
    password.send_keys(passs)

    sleep (3)

    login_form = webdriver.find_element_by_xpath('//*[@id= "react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button/div')
    login_form.click()

    sleep(3) #Change this to more of a value if you ahve to manually login because of Instagram labelling it as a 'Suspicious attempt'

    notif = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
    notif.click()
Exemplo n.º 15
0
def chSelect(webdriver):
    """
    Generates a Select object from the chapter list found in any page.
    
    return: Selenium's Select object
    """
    chapter_list = webdriver.find_element_by_name("chapter_select")
    select_object = Select(chapter_list)
    return select_object
Exemplo n.º 16
0
def pgGetList(webdriver):
    """
    Gets the chapter list.
    webdriver: Selenium's webdriver object
    
    return: Select object
    """
    page_list = webdriver.find_element_by_name("page_select")
    return Select(page_list)
Exemplo n.º 17
0
def login():
    username = webdriver.find_element_by_name('username')
    username.send_keys(secret.username)
    password = webdriver.find_element_by_name('password')
    password.send_keys(secret.password)
    sleep(2)
    button_login = webdriver.find_element_by_xpath(
        '/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[4]/button'
    )
    button_login.click()
    sleep(10)

    try:
        notnow = webdriver.find_element_by_css_selector(
            'button.aOOlW:nth-child(2)')
        notnow.click(
        )  # comment these last 2 lines out, if you don't get a pop up asking about notifications
    except NoSuchElementException:
        pass
Exemplo n.º 18
0
def LoggingIn(user, passs):
    username = webdriver.find_element_by_name('username')
    username.send_keys(user)

    password = webdriver.find_element_by_name('password')
    password.send_keys(passs)

    sleep(3)

    login_form = webdriver.find_element_by_xpath(
        '//*[@id= "react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button/div'
    )
    login_form.click()

    sleep(3)

    notif = webdriver.find_element_by_css_selector(
        'body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
    notif.click()
Exemplo n.º 19
0
def login():
    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher')
    sleep(3)
    username = webdriver.find_element_by_name('username')
    username.send_keys('official_rakshit')
    password = webdriver.find_element_by_name('password')
    password.send_keys('')
    button_login = webdriver.find_elements_by_xpath(
        "//*[contains(text(), 'Log In')]")
    button_login[0].click()
    sleep(5)
    notnow = webdriver.find_elements_by_xpath(
        "//*[contains(text(), 'Not Now')]")
    notnow[0].click()
    sleep(3)
    notnow = webdriver.find_elements_by_xpath(
        "//*[contains(text(), 'Not Now')]")
    notnow[0].click()
    sleep(3)
Exemplo n.º 20
0
def form_data(webdriver):
    input1 = webdriver.find_element_by_tag_name("input")
    input1.send_keys("Ivan")
    input2 = webdriver.find_element_by_name("last_name")
    input2.send_keys("Petrov")
    input3 = webdriver.find_element_by_class_name("city")
    input3.send_keys("Smolensk")
    input4 = webdriver.find_element_by_id("country")
    input4.send_keys("Russia")
    button = webdriver.find_element_by_xpath(xpath)
    button.click()
    return
Exemplo n.º 21
0
def login_code(cachePath, userId, password):
    global webdriver
    file = pathlib.Path(cachePath)
    flag = file.exists()
    chrome_options = Options()
    chromedriver_path = '/Users/shaurya/Desktop/Shaurya/pyinstagram/webdriver/chromedriver'
    chrome_options.add_argument('--user-data-dir={}'.format(cachePath))
    if args.headless == 'True':
        chrome_options.add_argument("--headless")
    webdriver = webdriver.Chrome(executable_path=chromedriver_path,
                                 options=chrome_options)
    sleep(2)
    print(flag)
    if flag == False:
        print('Cache Doesnot exist')
        webdriver.get(
            'https://www.instagram.com/accounts/login/?source=auth_switcher')
        sleep(3)
        webdriver.maximize_window()
        logger.info("Not Cached: Instagram Site Open")

        username = webdriver.find_element_by_name('username')
        username.send_keys(userId)
        p_word = webdriver.find_element_by_name('password')
        p_word.send_keys(password)
        logger.info("Id {}, Password Entered".format(userId))

        button_login = webdriver.find_element_by_css_selector(
            '#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child(4)'
        )
        button_login.click()
        sleep(3)
    else:
        webdriver.get('https://www.instagram.com')
        sleep(3)
        webdriver.maximize_window()
        logger.info("Cached: Instagram Site Open")

    return webdriver
Exemplo n.º 22
0
def create_insta_ac(email0):
    
 insta_username3=input("[*] Enter Username For Insta [Good] : ")
 insta_pass3=input("[*] Enter Password For Insta : ")
 insta_fullname3=input("[*] Enter FullName For Insta : ")

 id_em='emailOrPhone'
 id_fulln='fullName'
 id_usname='username'
 id_passw='password'
 url2="https://www.instagram.com/"
 chromedriver_path = r'C:\Users\Orkideh\Downloads\chromedriver_win32/chromedriver.exe' # Change this to your own chromedriver path!
 webdriver = webdriver.Chrome(executable_path=chromedriver_path)
 sleep(2)
 webdriver.get(url2)
 username_insts = webdriver.find_element_by_name(id_usname)
 pass_insts = webdriver.find_element_by_name(id_passw)
 em_insts = webdriver.find_element_by_name(id_em)
 fullname_insts = webdriver.find_element_by_name(id_fulln)
 em_insts.send_keys(email0)
 fullname_insts.send_keys(insta_fullname3)
 username_insts.send_keys(insta_username3)
 pass_insts.send_keys(insta_pass3)
Exemplo n.º 23
0
def find(webdriver, by, css_selector_val):
    '''
    Wrapper function of selenium python to find an elment using locator and locator_value(css_selector_val)

    Arguments
    ---------

    webdriver       -   object of selenium.webdriver.chrome.webdriver.WebDriver .
    by              -   element locator name .
                        contraint:
                            expected value:-    id, name, xpath, link_text, partial_link_text, 
                                                tag_name, class_name, css_selector 
                        other value than the expected will return None
    css_selector_val-   value for the element locator i.e. arg 'by' 
                        example:- to find all elements with class_name=contact, value for css_selector_val is 'contact'
    
    Return
    ---------
    Webelement      -   if the value of arg 'by' is an expected value
    or
    None            -   if the value of arg 'by' is an unexpected value
    '''

    if by == 'id':
        return webdriver.find_element_by_id(css_selector_val)
    if by == 'name':
        return webdriver.find_element_by_name(css_selector_val)
    if by == 'xpath':
        return webdriver.find_element_by_xpath(css_selector_val)
    if by == 'link_text':
        return webdriver.find_element_by_link_text(css_selector_val)
    if by == 'partial_link_text':
        return webdriver.find_element_by_partial_link_text(css_selector_val)
    if by == 'tag_name':
        return webdriver.find_element_by_tag_name(css_selector_val)
    if by == 'class_name':
        return webdriver.find_element_by_class_name(css_selector_val)
    if by == 'css_selector':
        return webdriver.find_element_by_css_selector(css_selector_val)
    else:
        return None
Exemplo n.º 24
0
hash=input()


# Change this to your own chromedriver path!
chromedriver_path = 'C:/Users/Vinay/Downloads/chromedriver_win32/chromedriver.exe' 
webdriver = wb.Chrome(executable_path=chromedriver_path)

sleep(2)
#opening instagram login page.
webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')

sleep(3)



username = webdriver.find_element_by_name('username')#finding username inputbox

username.send_keys(user)#passing username.

password = webdriver.find_element_by_name('password')
password.send_keys(passw)


#finding login button 
button_login = webdriver.find_element_by_css_selector('#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child() > button')
#clicking on button 
button_login.click()

sleep(3)

Exemplo n.º 25
0
__author__ = 'Karan.Patel'

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

#location of the chromedriver
webdriver = webdriver.Chrome(
    "C:\Users\Karan\Downloads\chromedriver_win32(2019)\chromedriver.exe")

webdriver.get(
    "https://wrem.sis.yorku.ca/Apps/WebObjects/REM.woa/wa/DirectAction/rem")
webdriver.get_screenshot_as_file("addCourse.png")
login = webdriver.find_element_by_name("loginform")
userElement = login.find_element_by_id("mli")
passElement = login.find_element_by_id("password")
loginButtonElement = webdriver.find_element_by_name("dologin")
#This is where you input your yorku passport username
userElement.send_keys("USER")
#This iswhere you input your yorku passport password
passElement.send_keys("PASS")

loginButtonElement.click()

webdriver.get_screenshot_as_file("confirmation.png")
WebDriverWait(webdriver, 10).until(EC.title_contains("REM - Main"))
webdriver.get_screenshot_as_file("enrollmentPage.png")
selection = webdriver.find_element_by_tag_name("select")
selection.click()
allOptions = selection.find_elements_by_tag_name("option")
Exemplo n.º 26
0
time.sleep(2)

# 打印当前页面上有多少个checkbox
print len(browser.find_elements_by_css_selector('input[type=checkbox]'))
time.sleep(2)
# 把页面上最后1个checkbox的勾给去掉
browser.find_elements_by_css_selector('input[type=checkbox]').pop().click()
###############################################层及定位#######################################################################
#点击Link1链接(弹出下拉列表)
browser.find_element_by_link_text('Link1').click()
from selenium.webdriver.support.ui import WebDriverWait
#找到id 为dropdown1的父元素
WebDriverWait(browser, 10).until(lambda the_driver: the_driver.find_element_by_id('dropdown1').is_displayed())#在父亲元件下找到link为Action的子元素
menu = browser.find_element_by_id('dropdown1').find_element_by_link_text('Action')

#鼠标定位到子元素上
webdriver.ActionChains(browser).move_to_element(menu).perform()

time.sleep(2)

browser.quit()
################################################上传文件########################################################################
#脚本要与upload_file.html同一目录
file_path =  'file:///' + os.path.abspath('upload_file.html')
webdriver.get(file_path)

#定位上传按钮,添加本地文件
webdriver.find_element_by_name("file").send_keys('D:\\selenium_use_case\upload_file.txt')
time.sleep(2)

webdriver.quit()
Exemplo n.º 27
0
    sleep(10)
    comm.send_keys(Keys.ENTER)
    sleep(20)
    # Next pic
    webdriver.find_element_by_link_text('Dalej').click()
    sleep(randint(15, 30))
    print(likes)


chromedriver_path = 'C:/Users/tomas/PycharmProjects/Repo_Learning/Web_Scraping/chromedriver.exe'  # Change this to your own chromedriver path!
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
sleep(2)
webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
sleep(3)

username = webdriver.find_element_by_name('username')
username.send_keys('*****@*****.**')
password = webdriver.find_element_by_name('password')
password.send_keys('Widzew01+')

login_in_enter = webdriver.find_element_by_name("password").send_keys(Keys.RETURN)

sleep(3)

alert_no = webdriver.find_element_by_class_name("mt3GC")
alert_no.click()

hashtag_list = ['traveler', 'landscape', 'drone', 'dronephotos', 'dronephotography', 'goprophotography',
                'traveldestination',
                'photographer', 'vacation', 'instatravel', 'travelblogger', 'photooftheday',
                'instapic', 'inspiration', 'instacool', 'happiness', 'blogger', 'travel',
Exemplo n.º 28
0
def login_instapls():



 chromedriver_path = r'C:\Users\Orkideh\Downloads\chromedriver_win32/chromedriver.exe' # Change this to your own chromedriver path!
 webdriver = webdriver.Chrome(executable_path=chromedriver_path)
 sleep(2)
 webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
 sleep(3)

 username = webdriver.find_element_by_name('username')
 username.send_keys(final_email)
 password = webdriver.find_element_by_name('password')
 password.send_keys(insta_pass3)

 button_login = webdriver.find_element_by_css_selector('body > div > section > main > div > article > div > div > div > form > div > button > div')
 button_login.click()
 sleep(3)

 notnow = webdriver.find_element_by_css_selector('body > div > div > div > div > div > button.aOOlW.HoLwm')
 notnow.click() #comment these last 2 lines out, if you don't get a pop up asking about notifications


 hashtag_list = ['vojood', 'gomshodim']

#############################################
 prev_user_list = []
 # - if it's the first time you run it, use this line and comment the two below

 #prev_user_list = pd.read_csv('20181203-224633_users_followed_list.csv', delimiter=',').iloc[:,1:2] # useful to build a user log
 #prev_user_list = list(prev_user_list['0'])

 new_followed = []
 tag = -1
 followed = 0
 likes = 0
 comments = 0

 for hashtag in hashtag_list:
     tag += 1
     webdriver.get('https://www.instagram.com/explore/tags/'+ hashtag_list[tag] + '/')
     sleep(5)
     first_thumbnail = webdriver.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div')
    
     first_thumbnail.click()
     sleep(randint(1,2))    
     try:        
         for x in range(1,200):
             username = webdriver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/article/header/div[2]/div[1]/div[1]/h2/a').text
            
             if username not in prev_user_list:
                 # If we already follow, do not unfollow
                 if webdriver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/article/header/div[2]/div[1]/div[2]/button').text == 'Follow':
                    
                     webdriver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/article/header/div[2]/div[1]/div[2]/button').click()
                    
                     new_followed.append(username)
                     followed += 1

                     # Liking the picture
                     button_like = webdriver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/article/div[2]/section[1]/span[1]/button/span')
                    
                     button_like.click()
                     likes += 1
                     sleep(randint(18,25))

                     # Comments and tracker
                     comm_prob = randint(1,10)
                     print('{}_{}: {}'.format(hashtag, x,comm_prob))
                     if comm_prob > 7:
                         comments += 1
                         webdriver.find_element_by_xpath('/html/body/div/div/div/div/article/div/section/span/button/span').click()
                         comment_box = webdriver.find_element_by_xpath('/html/body/div/div/div/div/article/div/section/div/form/textarea')

                         if (comm_prob < 7):
                             comment_box.send_keys('dada eyval!')
                             sleep(1)
                         elif (comm_prob > 6) and (comm_prob < 9):
                             comment_box.send_keys('Nice work :)')
                             sleep(1)
                         elif comm_prob == 9:
                             comment_box.send_keys('Nice TRACK!!')
                             sleep(1)
                         elif comm_prob == 10:
                             comment_box.send_keys('So cool! :)')
                             sleep(1)
                         # Enter to post comment
                         comment_box.send_keys(Keys.ENTER)
                         sleep(randint(22,28))

                 # Next picture
                 webdriver.find_element_by_link_text('Next').click()
                 sleep(randint(25,29))
             else:
                 webdriver.find_element_by_link_text('Next').click()
                 sleep(randint(20,26))
     # some hashtag stops refreshing photos (it may happen sometimes), it continues to the next
     except:
         continue

 for n in range(0,len(new_followed)):
     prev_user_list.append(new_followed[n])
    
 updated_user_df = pd.DataFrame(prev_user_list)
 updated_user_df.to_csv('{}_users_followed_list.csv'.format(strftime("%Y%m%d-%H%M%S")))
 print('Liked {} photos.'.format(likes))
 print('Commented {} photos.'.format(comments))
 print('Followed {} new people.'.format(followed))
Exemplo n.º 29
0
def unfollow_it(uname_,pass_,tkWindow):
    import os
    from time import sleep
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    full_path = os.path.realpath(__file__)
    location_input=os.path.dirname(full_path)

    filename=location_input+"\\followed_by_script.txt"
    if not os.path.exists(filename):
        print("File Not Found")
        exit()

    file_=open(filename,'r')
    array_of_names=[]
    while True:
        lines=file_.readline()
        if not lines:
            break
        array_of_names.append(lines)
    if len(array_of_names)==0:
        print("No records found...")
        exit()


    chromedriver_path = location_input+'\chromedriver.exe' 
    webdriver = webdriver.Chrome(executable_path=chromedriver_path)
    sleep(2)
    print("Loading login page...")
    webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
    sleep(3)
    try:
            print("Logging in...")
            username = webdriver.find_element_by_name('username')
            username.send_keys(str(uname_))
            password = webdriver.find_element_by_name('password')
            password.send_keys(str(pass_))
            button_login = webdriver.find_element_by_xpath('//button[normalize-space()="Log In"]')
            button_login.click()
            print("Logged in Successfully")
    except:
        print("Re run the program..")
        tkWindow.destroy()
        exit(1)

    sleep(10)
    try:
        notnow = webdriver.find_element_by_css_selector('#react-root > section > main > div > div > div > div > button')
        notnow.click()
        print("Closed Save Details Message.")
    except:
        print("No Save Detail Message Appeared")
    try:
        notnow = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm')
        notnow.click() #comment these last 2 lines out, if you don't get a pop up asking about notifications
        print("Closed allow notification PopUp.")
    except:
        sleep(10)
        notnow = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm')
        notnow.click() #comment these last 2 lines out, if you don't get a pop up asking about notifications
        print("Closed allow notification PopUp.")

    unfollowed=0
    print("Unfollowing all followed profiles by Script.")
    for names in array_of_names:
        print("Loading profile: "+names)
        webdriver.get('https://www.instagram.com/'+names+'/')
        sleep(3)
        try:
            unfollow_button=webdriver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/header/section/div[1]/div[1]/div/div[2]/div/span/span[1]/button')
            unfollow_button.click()
            sleep(1)
            confirm_button=webdriver.find_element_by_xpath('/html/body/div[5]/div/div/div/div[3]/button[1]')
            confirm_button.click()
            sleep(1)
            unfollowed+=1
            try:
                with open(filename, "r+") as f:
                    d = f.readlines()
                    f.seek(0)
                    for i in d:
                        if i != names:
                            f.write(i)
                    f.truncate()
            except:
                print("File Not Found")
            print("Unfollowed : {}".format(names))
        except:
            continue

    print("Unfollowed : {}".format(unfollowed))
    tkWindow.destroy()
    exit(1)
Exemplo n.º 30
0
def user7():
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from time import sleep
    from user8 import user8

    # Opens the Chrome browser and go to the login Instagram page.
    driverPath = 'D:\Programming\Python Projects\Personal Projects\chromedriver.exe'
    webdriver = webdriver.Chrome(executable_path=driverPath)
    webdriver.get(
        'https://www.instagram.com/accounts/login/?source=auth_switcher')
    sleep(2)

    # Holds the user's username and password that will be used.
    username = ''
    password = ''

    # Find the username and password elements and fills them in with the user's login.
    userElement = webdriver.find_element_by_name('username')
    userElement.send_keys(username)
    passElement = webdriver.find_element_by_name('password')
    passElement.send_keys(password)

    # Find the login button element and click it to login into the user's account.
    login = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div:nth-child(4) > button > div'
    )
    login.click()
    sleep(3)

    # Find the "Not Now" element of the notification popup and click it to make it go away.
    notNow = webdriver.find_element_by_css_selector(
        'body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
    notNow.click()
    sleep(1)

    # Direct the browser to Blanson's Chick-fil-a page.
    webdriver.get('https://www.instagram.com/p/B2epau2FUiI/')
    sleep(1)

    # Find the comment box on the page and click on it.
    commentBox = webdriver.find_element_by_css_selector(
        '#react-root > section > main > div > div > article > div.eo2As > section.sH9wk._JgwE > div > form > textarea'
    )
    commentBox.click()

    # This will be the comment that will be posted.
    comment = 'Blanson Bold! Blanson Gold!'

    # Comment infinitely (will be stopped inevitably by Instagram however).
    while True:
        # Find the comment box again to let the program know we are working with it again.
        commentBox = webdriver.find_element_by_css_selector(
            '#react-root > section > main > div > div > article > div.eo2As > section.sH9wk._JgwE > div > form > textarea'
        )
        # Input the comment in the comment box.
        commentBox.send_keys(comment)
        # Enter to post the comment.
        commentBox.send_keys(Keys.ENTER)
        sleep(.5)
        # Try to scan the page for the popup that blocks the user from commenting.
        try:
            webdriver.find_element_by_css_selector(
                'body > div.Z2m7o > div > div > div > p')
            sleep(2)
            # If it gets to this point then it has blocked the user, and we close this browser.
            webdriver.close()
            # Call the next function to start another browser and user.
            user8()
        # If it is not there, then it will cause an error and we will let the program run normally.
        except:
            pass
        # Wait 7 seconds to give the comment time to be uploaded.
        sleep(7)
Exemplo n.º 31
0
import pandas as pd
from openpyxl import load_workbook
import os
import sys

dirname = 'D:\\Report\\1398\\TabdilVaz'
progdirname = os.path.dirname(__file__)

chromedriver_path = r'D://chromedriver/lib/chromedriver/chromedriver.exe'  # Change this to your own chromedriver path!
webdriver = webdriver.Chrome(executable_path=chromedriver_path)

webdriver.get('http://amarnameh.imo.org.ir')

userData = open("userData.udata", "r")

username = webdriver.find_element_by_name('txtUsername')
username.send_keys(userData.readline().rstrip())
password = webdriver.find_element_by_name('txtPassword')
password.send_keys(userData.readline().rstrip())

webdriver.find_element_by_xpath('//*[@id="ctl01"]/div[6]/div').click()
companies = userData.readline().rstrip().split(',')
print(companies)
# companies = ['SazMotori','SazMotori']
forms = userData.readline().rstrip().split(',')
excelfile = userData.readline().rstrip()
if len(sys.argv) >= 2:
    excelfile = sys.argv[1]
if len(sys.argv) >= 3:
    forms = sys.argv[2].split(',')
print(forms)
#browser = Browser()

fp = webdriver.FirefoxProfile()

fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.dir", "/home/dhl/download")
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")

webdriver = webdriver.Firefox(firefox_profile=fp)

webdriver.get('https://nolb.dhl.de/nextt-online-business/jsp/login.do')

#Loging in
webdriver.find_element_by_id('login').send_keys('user')
webdriver.find_element_by_id('password').send_keys('password')
webdriver.find_element_by_name('doLogin').click()

f = open("/home/dhl/shipment_numbers.csv")

wait = WebDriverWait(webdriver, 60 * 60)

for line in f:
	#Searching for shipment code
	webdriver.find_element_by_id('shipmentCode').send_keys(line)
	webdriver.find_element_by_id('timeIntervall').send_keys('12')
	webdriver.find_element_by_name('search_ta').click()
	#Downloading pdf
	try:
	    actionSelection = wait.until(EC.element_to_be_clickable((By.ID,'pageActionSelect')))
	finally:
		pass
Exemplo n.º 33
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep, strftime
from random import randint
import pandas as pd

chromedriver_path = '/usr/bin/chromedriver'  # Change this to your own chromedriver path!
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
sleep(2)
webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
sleep(3)

username = webdriver.find_element_by_name('username')
username.send_keys('')  #specify username
password = webdriver.find_element_by_name('password')
password.send_keys('')  #specify password
button_login = webdriver.find_element_by_css_selector(
    '#react-root > section > main > div > article > div > div > div > form > div > button'
)
button_login.click()
sleep(3)
notnow = webdriver.find_element_by_css_selector(
    'body > div.RnEpo.Yx5HN> div > div > div.mt3GC > button.aOOlW.HoLwm')
notnow.click(
)  #comment these last 2 lines out, if you don't get a pop up asking about notifications

hashtag_list = ['fcbarcelona', 'chelsea', 'manchestercity']

prev_user_list = [
]  #- if it's the first time you run it, use this line and comment the two below
# prev_user_list = pd.read_csv('20181203-224633_users_followed_list.csv', delimiter=',').iloc[:,
Exemplo n.º 34
0
'''
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
# chrome_options.add_argument('--headless') # allows for running in a silent window
'''
Defining Selenium WebDriver with Chrome
'''
# chromedriver_path = *FILE DIRECTORY PATH TO chrome.exe*
webdriver = webdriver.Chrome(options=chrome_options)
webdriver.get("https://www.bestbuy.com/identity/signin?token=tid%3A76cd7b18-1f73-11eb-a502-121fb7f40979")
#sleep(3)

secretemail=open("email.txt",'r')
myemail=secretemail.read()
email=webdriver.find_element_by_name("fld-e")
email.send_keys(myemail)
secretpass=open("pass.txt",'r')
mypass=secretpass.read()
password=webdriver.find_element_by_name("fld-p1")
password.send_keys(mypass)

LOGIN_BUTTON_XPATH="/html/body/div[1]/div/section/main/div[1]/div/div/div/div/form/div[4]/button"
button_login=webdriver.find_element_by_xpath(LOGIN_BUTTON_XPATH)
button_login.click()

sleep(5)
X_BUTTON_XPATH="/html/body/main/div[2]/div[5]/div/div/div[1]/div/div/div/div/button"

x_it_out=webdriver.find_element_by_xpath(X_BUTTON_XPATH)
x_it_out.click()