search

Home  >  Q&A  >  body text

python3.x - python多进程,不能在同一窗口吗

web=webdriver.Firefox()
web.get()

def work1():
    pass
def work2():
    pass
def work3():
    pass

w1 = Process(target=work1,name='w1')
w2 = Process(target=work2,name='w2')
w3 = Process(target=work3,name='w3')

w1.start()
w2.start()
w3.start()

这样web.get()会打开一个firefox. 三个进程也打开三个firefox。
这下就四个了。
我是想能不能让它们只打开一个firefox工作???

(不用线程)
(语法不是问题的重点,只是说明问题随手打的)

阿神阿神2873 days ago703

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:27:42

    Can’t.
    The questioner means to use multi-threading to obtain web page information. However, an HTML document must occupy a window. Modern browsers use tabs to solve this problem. Then the questioner can set the default use of tabs to open the window in Firefox.
    Also, all windows should be opened in the main thread, and then the window objects should be passed to the child process. Otherwise, Firefox will think that it is being called by multiple processes.

    reply
    0
  • 阿神

    阿神2017-04-18 10:27:42

    Can you open multiple tabs?

    reply
    0
  • Cancelreply