“Screenshot Selenium Agen Pengguna Python” Kode Jawaban

Screenshot Selenium Agen Pengguna Python

#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

Screenshot Selenium Agen Pengguna Python

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

Jawaban yang mirip dengan “Screenshot Selenium Agen Pengguna Python”

Pertanyaan yang mirip dengan “Screenshot Selenium Agen Pengguna Python”

Lebih banyak jawaban terkait untuk “Screenshot Selenium Agen Pengguna Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya