title: Python Proxy Scraper / Checker adding multi-threading trouble
body: <p>I have managed to piece together a proxy scraper/checker, it does work but it is quite slow. I have heard that adding threading can speed up the process, this is past what I am capable of and am wondering if anyone can help show me how to implement threading into the code. I read that the threading library is included with python, I had an attempt at adding it but it seemed to create a second thread doing exactly the same, so it was just going through the same list of proxies at the same time saving duplicates. here is the code.</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  from random import choice
  import threading
  import time
      
  stop_flag = 0
      
  def get_proxies():
      link = 'https://api.proxyscrape.com/?request=displayproxies&amp;proxytype=all&amp;timeout=5000&amp;country=all&amp;anonymity=all&amp;ssl=no'
      other = 'https://www.proxy-list.download/api/v1/get?type=http'
      get_list1 = requests.get(link).text
      get_list2 = requests.get(other).text
      soup1 = BeautifulSoup(get_list1, 'lxml')
      soup2 = BeautifulSoup(get_list2, 'lxml')
      list1 = soup1.find('body').get_text().strip()
      list2 = soup2.find('body').get_text().strip()
      mix = list1+'\n'+list2+'\n'
      raw_proxies = mix.splitlines()
      t = threading.Thread(target=check_proxy, args=(raw_proxies,))
      t.start()
      time.sleep(0.5)
      return check_proxy(raw_proxies)
  
  def check_proxy(proxies):
      check = 'http://icanhazip.com'       
      for line in proxies:
  
          headers = {&quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0&quot;,&quot;Accept-Encoding&quot;: &quot;*&quot;,&quot;Connection&quot;: &quot;keep-alive&quot;}
          try:    
              response = requests.get(check, proxies={'http': 'http://'+line}, headers=headers, timeout=5)
              status = response.status_code
  
              outfile = open('good_proxies.txt', 'a')
              if status is 200:
                  print('good - '+line)
                  outfile.write(line+'\n')
              else:
          
                  pass
          except Exception:
              print('bad  - '+line)
      outfile.close()        
  
  get_proxies()
  </code></pre>