Chào mọi người , mình là newbie mới tập thành python . mình đang thử viết 1 đoạn code chạy profile chrome bằng selenium , mọi người cho mình hỏi mình muốn lấy useragent trong file txt theo thứ tự từ trên xuống để chạy mà mãi không được , nhờ các bạn xem dùm code giúp mình với ạ . thanks nhiều
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())