“Selenium screenshot python user agente” Respostas de código

Selenium screenshot python user agente

#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())
Determined Dog

Selenium screenshot python user agente

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
Magnificent Mole

Respostas semelhantes a “Selenium screenshot python user agente”

Perguntas semelhantes a “Selenium screenshot python user agente”

Mais respostas relacionadas para “Selenium screenshot python user agente” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código