Answers for "selenium screenshot python user agent"

0

selenium screenshot python user agent

#I want each time chrome opens it will automatically run with a useragent taken from the txt file in order from line 1 -> line 10 . I'm a new member, someone please help me

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

key="something"
while key != "q":    
 username_list = list()
 with open("a.txt") as file:
     for line in file:
        agent = line.split(':')
        username_list.append((agent))  
 options = Options()
 options.add_argument(f'user-agent={agent[0]}')
 driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Program 
Files (x86)\chromedriver.exe')
 driver.get("https://www.deviceinfo.me/")
 time.sleep(5) # Let the user actually see something!
 driver.quit()
key=str(input())
Posted by: Guest on August-27-2021
0

selenium screenshot python user agent

from selenium import webdriver

user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'

options = webdriver.ChromeOptions()
# specify headless mode
options.add_argument('headless')
# specify the desired user agent
options.add_argument(f'user-agent={user_agent}')
driver = webdriver.Chrome(chrome_options=options)

# user-agent is now set
Posted by: Guest on June-26-2020

Code answers related to "selenium screenshot python user agent"

Python Answers by Framework

Browse Popular Code Answers by Language