当前位置: 首页> 财经> 产业 > 专属头像制作素材图片_关键词大全_宁波网站推广专业服务_长沙网站搭建关键词排名

专属头像制作素材图片_关键词大全_宁波网站推广专业服务_长沙网站搭建关键词排名

时间:2025/7/9 11:23:21来源:https://blog.csdn.net/G971005287W/article/details/144557463 浏览次数:0次
专属头像制作素材图片_关键词大全_宁波网站推广专业服务_长沙网站搭建关键词排名

【Python】使用Selenium 操作浏览器 记录

1.安装python

2.安装 selenium

pip install selenium

3.安装Chrome浏览器驱动

【附件】Selenium chromedriver 驱动及浏览器下载-CSDN博客文章浏览阅读42次。【附件】Selenium chromedriver 驱动及浏览器下载。https://blog.csdn.net/G971005287W/article/details/144556634

from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.edge.options import Options as EdgeOptions
import timedef main():# 设置Edge选项edge_options = EdgeOptions()edge_options.add_argument('--start-maximized')  # 窗口最大化启动user_data_dir = r'C:\Users\Administrator\AppData\Local\Microsoft\Edge\User Data'  # Windows 示例路径,请替换为实际路径edge_options.add_argument(f'--user-data-dir={user_data_dir}')  # 窗口最大化启动# 如果需要指定Profile,可以添加 --profile-directory 参数# profile_directory = 'Profile 5'  # 替换为你要使用的具体Profile名称profile_directory = 'Default'  # 替换为你要使用的具体Profile名称edge_options.add_argument(f'--profile-directory={profile_directory}')# edge_options.add_argument("--headless")# 指定Edge WebDriver的位置service = EdgeService(executable_path='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver.exe')# service = EdgeService(executable_path=executable_path)# 创建一个新的Edge浏览器实例,并启用无痕模式driver = webdriver.Edge(service=service, options=edge_options)driver.set_window_size(300, 500)# 打开目标网页driver.get('https://www.baidu.com')print('打开第一个浏览器')# 设置Edge选项edge_options2 = EdgeOptions()edge_options2.add_argument('--start-maximized')  # 窗口最大化启动# edge_options2.add_argument("--headless")user_data_dir2 = r'C:\Users\Administrator\AppData\Local\Microsoft\Edge\User Data2'  # Windows 示例路径,请替换为实际路径edge_options2.add_argument(f'--user-data-dir={user_data_dir2}')  # 窗口最大化启动# 如果需要指定Profile,可以添加 --profile-directory 参数# profile_directory2 = 'Profile 5'  # 替换为你要使用的具体Profile名称profile_directory2 = 'Default'  # 替换为你要使用的具体Profile名称edge_options2.add_argument(f'--profile-directory={profile_directory2}')# 指定Edge WebDriver的位置service2 = EdgeService(executable_path='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver2.exe')# service = EdgeService(executable_path=executable_path)# 创建一个新的Edge浏览器实例,并启用无痕模式driver2 = webdriver.Edge(service=service2, options=edge_options2)driver2.set_window_size(300, 500)# 打开目标网页driver2.get('https://www.baidu.com')print('打开第二个浏览器')time.sleep(500000000)if __name__ == "__main__":main()

关键字:专属头像制作素材图片_关键词大全_宁波网站推广专业服务_长沙网站搭建关键词排名

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: