dimanche 30 décembre 2018

Unable to open Instagram mobile version using Selenium?

So, I am trying to create an automated bot to post on Instagram but I have not been able to open mobile version of Instagram using selenium.

I have tried using

from selenium.webdriver.common.keys import Keys
chrome_options = Options()
chrome_options.add_argument("--window-size=200,700")

To set the size of my chrome window in selenium but It still opens the desktop version.

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys

def site_login():
    driver = webdriver.Chrome(executable_path='//home/kartikey/Desktop/Files/Insta_Bot/chromedriver',chrome_options=chrome_options)
    driver.get ('https://www.instagram.com/accounts/login/')
    time.sleep(3)
    # To login
    driver.find_element_by_name("username").send_keys('EMAIL')
    passwordInput = driver.find_element_by_name("password")
    passwordInput.send_keys('*******')
    passwordInput.send_keys(Keys.ENTER)
    # To turn on Notifications
    driver.find_element_by_xpath('/html/body/div[3]/div/div/div/div[3]/button[1]').click() 
    return None
site_login()

I am able to access the desktop version but desktop version doesn't allow posting.

So, I want to know how can I use selenium so that I can open mobile version of Instagram ?

Thanks in Advance




Aucun commentaire:

Enregistrer un commentaire