首页 > 代码库 > selenium多进程

selenium多进程

import os
import multiprocessing

1、获取Chromedriver驱动动态路径
webdriver.Chrome(executable_path=os.path.join(os.getcwd(), "chromedriver.exe"))
2、等待特地(label)网页元素加载完毕,返回真
is_disappeared = WebDriverWait(dr, 30, 1, ignored_exceptions=TimeoutException).until(lambda x: x.find_element_by_id("label").is_displayed())
3、多进程
if __name__ == ‘__main__‘:
  multiprocessing.freeze_support()
  
pool = multiprocessing.Pool(processes=3)
  
for i in range(2):
    pool.apply_async(func,args=(args,))
  pool.close() 
  pool.join()



selenium多进程