火狐浏览器设置请求头的具体方法如下:
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium import webdriver from fake_useragent import UserAgent import time option=FirefoxProfile() ua = UserAgent() user_agent=ua.firefox print(user_agent) option.set_preference("general.useragent.override", user_agent) browser = webdriver.Firefox(option) browser.get('http://www.baidu.com') time.sleep(3)
这里我已经验证了两次,如下图
评论