Selenium

import sys
import time
from selenium import webdriver

def driver_get(url):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_ecperimental_option(‘excludeSwitches‘, [‘enable-automation‘])
chrome_options.add_ecperimental_option(‘useAutomationExtension‘, False)
chrome_options.add_ecperimental_option(‘prefs‘, {‘profile.default_countent_setting_values‘: {‘image‘:2}})
chrome_options.add_ecperimental_option(‘--disable-infobars‘)
chrome_options.add_ecperimental_option(‘--start_maximized‘)
chrome_options.add_ecperimental_option(‘--headless‘)
chrome_options.add_ecperimental_option(‘--incognito‘)
chrome_options.add_ecperimental_option(‘--disable-gpu‘)
chrome_options.add_ecperimental_option(‘--no-sandbox‘)
chrome_options.add_ecperimental_option(‘lang=en_US‘)
chrome_options.add_ecperimental_option("user-agent=Mxxxxxxxxx")
CHROMEDRIVER_PATH = ‘/opt/xxxx/chromedriver_83.0.4103‘
CHROMEDRIVER_PATH = ‘C:\Users\username\chromedriver.exr‘
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=chrome_options)
driver.get(url)
time.sleep(3)
print(driver.page_source)
driver.close()
driver.quit()

Selenium

上一篇:软件测试分类


下一篇:视频追踪