from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
import os
import re
import random
import traceback
import time,json
from io import BytesIO
import requests
url_save_dict = [
{
"url":"博主主页",
"save_path": "C:/Users/wtc/Desktop/test",
},
]
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3')
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False) #关闭提示自动运行
chrome_options.add_argument("--remote-allow-origins=*")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--auto-open-devtools-for-tabs")
chrome_options.set_capability("goog:loggingPrefs", {"performance":"ALL"})
chrome_options.binary_location = ("D:/chrome-win64/chrome-win64/chrome.exe")
prefs = {
"download.default_directory": "C:/Users/wtc/Desktop/tu", # 设置默认下载路径
"download.prompt_for_download": False, # 禁用下载确认弹窗
"download.directory_upgrade": True,
}
chrome_options.add_experimental_option("prefs", prefs)
drive