简体   繁体   English

如何使用python打开异步几个selenium webdriver

[英]How can I open async several selenium webdriver using python

Please help!请帮忙! I want to open several webdrivers and for each do different actions, for example for first opened webdriver do login, for second registration etc. I try to use Pool library, but it doesn't work correctly, it opens webdrivers not paraller.我想打开几个 webdrivers 并为每个做不同的操作,例如第一次打开的 webdriver 做登录,第二次注册等。我尝试使用 Pool 库,但它不能正常工作,它打开的 webdrivers 不是并行的。

from multiprocessing import Pool
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

class C:
    def log(self,  url):
        print("1")
        chrome_options = Options()
        chrome_options.add_argument("--start-maximized")
        driver = webdriver.Chrome("C:/Users/path")
        driver.get(url)

    def reg(self, url):
        print("2")
        chrome_options = Options()
        chrome_options.add_argument("--start-maximized")
        driver = webdriver.Chrome("C:/Users/path")
        driver.get(url)


    def f(self, *name):
        return name

    def run(self):
        pool = Pool(processes=2)
        pool.map(self.f, (self.log("someurl?form=sign_in"), self.reg("someurl?form=sign_up")))

if __name__ == '__main__':
    c = C()
    c.run()

我认为Selenium Grid 4正是您要找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 selenium/webdriver 打开网站? - How can I open websites with selenium/webdriver? 如何在 python 中使用 selenium webdriver 滚动 web 页面? - How can I scroll a web page using selenium webdriver in python? 如何使用Selenium WebDriver和python打开功能齐全的Chrome浏览器? - How to open a fully functioning chrome browser using selenium WebDriver with python? 如何使用python的Selenium WebDriver在浏览器上打开一个新的window? - How to open a new window on a browser using Selenium WebDriver for python? 如何使用Selenium的Webdriver在mail.ru中打开字母? - How can I open a letter in mail.ru using selenium's webdriver? 使用 Python Selenium Webdriver 打开 Electron 应用程序 - Using Python Selenium Webdriver to open Electron Application 我可以在python中使用Selenium Webdriver滚动网页吗 - can I scroll a web page using selenium webdriver in python 如何在python中使用Selenium Webdriver滚动网页以抽搐? - How can I scroll a web page using selenium webdriver in python, for twitch? 我如何在不被发现的情况下抓取网站并通过Python使用Selenium Webdriver绕过reCAPTCHA? - How can I scrape a website without getting detected and bypassing reCAPTCHA using selenium webdriver through Python? 如何在python中使用Selenium Webdriver滚动动态网页的特定部分? - How can I scroll a particular section of a dynamic web page using selenium webdriver in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM