1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

How do you guys login with Selenium and Adwords?

Discussion in 'Programming' started by sixpack.vincent, Oct 30, 2017.

  1. sixpack.vincent

    sixpack.vincent Newbie

    Joined:
    Dec 28, 2016
    Messages:
    15
    Likes Received:
    0
    Gender:
    Male
    I am currently building a reporting tool with Selenium on Adwords. I don't want to use their API for obvious reasons.

    I am trying to avoid logging in and logging out, because I understand frequent logins and logouts are not as convenient as cookie based authentication.

    I have the following code: save.py

    Code:
        try:
          driver = webdriver.Chrome()
          driver.get('#adwords home page')
          time.sleep(90)
          # Manually login to adwords page and wait
          pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
       
        finally:
          driver.close()
    
    And this: load.py

    Code:
        try:
          driver = webdriver.Chrome()
          cookies = pickle.load(open("cookies.pkl", "rb"))
          for cookie in cookies:
            driver.add_cookie(cookie)
       
          driver.get('#adwords home page')
          time.sleep(60)
       
        finally:
          driver.close()
    
    When I first run load.py, I am actually able to see the spinner that shows up when one logs into Adwords. Shortly after however, I get logged out!

    I don't know what is causing Google's authentication system to log me out. What do you think is the cause of this?
     
  2. sixpack.vincent

    sixpack.vincent Newbie

    Joined:
    Dec 28, 2016
    Messages:
    15
    Likes Received:
    0
    Gender:
    Male
    Note that I substituted '#adwords home page' with the actual site of adwords.
     
  3. Triveria Felix

    Triveria Felix Newbie

    Joined:
    Oct 31, 2017
    Messages:
    5
    Likes Received:
    1
    Probably google knows that you use bot in their authentication page.
     
  4. popisking

    popisking Junior Member

    Joined:
    Oct 27, 2016
    Messages:
    101
    Likes Received:
    30
    Gender:
    Male
    Make sure host HTTP header verification matches siteurl domain.