|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
selenium多开chrome添加profile_directory参数后能多开了但是总是要点击登陆一下怎么去掉这个登录的过程- from selenium.webdriver import Chrome
- from selenium.webdriver import ChromeOptions
- import engine_url
- USER_DATA = '--user-data-dir=.\Plug-In\\Google\\User Data\\profile '
- PERSONAL_INFORMATION = '--profile-directory=.\Plug-In\\Google\\User Data\\profile '
- def open_explorer(count,url):
- while 1:
- try:
- exec(f'chrome_option{count} = ChromeOptions()')
- exec(f'chrome_option{count}.binary_location = \'.\\plug-in\\Google\\Chrome\\Application\\chrome.exe\'')
- exec(f'chrome_option{count}.add_argument(USER_DATA+str(count))')
- exec(f'chrome_option{count}.add_argument(PERSONAL_INFORMATION+str(count)+\'Default\')')
- exec(f'chrome_driver{count} = Chrome(options=chrome_option{count},executable_path=\'.\\plug-in\\chromedriver.exe\')')
- exec(f'chrome_driver{count}.get(url)')
- break
- except:
- count += 1
- def main(args,sign):
- keyword = args.get('keyword')
- count = 1
- if keyword:
- for each in args['engine']:
- open_explorer(count,engine_url.search[each] + keyword)
- count += 1
- # 使用主页网站
- else:
- for each in args['engine']:
- open_explorer(count,engine_url.home_page[each])
- count += 1
-
- return f'成功进行了搜索,搜索的关键字为{args["keyword"]}'
复制代码
|
|