title: Python: Multiprocessing in a simple loop
body: <p>My objective is to get the <strong>source code of various web pages</strong> with the Selenium Driver Package. To use idle time while opening pages, I would love to <strong>make use of multiprocessing</strong>. However, as I am new to multiprocessing, I do not manage to make my code work.</p>
  <p>This is a <strong>simple function</strong> that serves as an example for what I would love to run in parallel (<em>selenium webdriver package and time package are required</em>):</p>
  <pre><code>def get_source(links):
      for i in range(len(links)):
          time.wait(3)
          driver.get(links[i])
          time.wait(3)
          print(driver.page_source)
          time.wait(3)
          print(&quot;Done with the page&quot;)
  </code></pre>
  <p>Different webpages are fed into this function, e.g.:</p>
  <pre><code>links = [&quot;https://stackoverflow.com/questions/tagged/javascript&quot;,&quot;https://stackoverflow.com/questions/tagged/python&quot;,&quot;https://stackoverflow.com/questions/tagged/c%23&quot;,&quot;https://stackoverflow.com/questions/tagged/php&quot;]
  </code></pre>
  <p>This is what I have so far. However, it does only spam instances of the webdriver instead of doing what it is intended to do, unfortunately.</p>
  <pre><code>if __name__ == '__main__':
      pool = Pool(2)
      pool.map(get_source(), links)
  </code></pre>
  <p>Any help is highly appreciated! Thanks a lot!</p>