from selenium import webdriver from selenium.webdriver.chrome.service import Service
def get_ck(): chromeOptions = webdriver.ChromeOptions() chromeOptions.add_argument('--user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36') chromeOptions.add_argument('--headless') chromeOptions.add_argument('--no-sandbox') chromeOptions.add_argument('--disable-gpu') driver = webdriver.Chrome(service=Service("/usr/bin/chromedriver"), options=chromeOptions)
drive.get("https://www.baidu.com")
driver.implicitly_wait(3)
driver.page_source
driver.close() driver.quit()
|