Git Product home page Git Product logo

croxxproxypool's Introduction

CroxxProxyPool

CroxxProxyPool is a light, thread-safe ProxyPool for Python that automatically crawl free proxies.

Advantages

  1. Thread-safe.
  2. Use a heap to make sure each time you will pop the earliest proxy you used.
  3. Confirm the availability of a proxy when it is crawled.
  4. Detect repeat proxies when pushing.
  5. [ Update on 2017-8-30 ] Crawl other proxies with a searched proxy to fasten searching available proxies ! ( Searching can be 2-5 times faster than before ! )

Usage

1.Import CroxxProxyPool

from CroxxProxyPool import ProxyPool

2.Get instance

pp = ProxyPool()
# get ProxyPool instance (ProxyPool is a singleton. You can only have ONE instance.)

3.Start crawling proxies

pp.start(delay = 10 * 60,ssl = True)
# start crawling proxies

4.Get a "http" or "https" proxy by pop()

proxy = pp.pop("HTTP") # or proxy = pp.pop("HTTPS")
# get a proxy ("HTTP" default)

5.Push the proxy back after using it

pp.push(proxy)
# push the proxy back to ProxyPool after using it

thread-safe

CroxxProxyPool is a thread-safe ProxyPool.

This is a multithreading emample.

(The log of function 'TsetProxy' is not thread-safe, for print in python2.7 is not thread-safe.)

from CroxxProxyPool import ProxyPool
import threading,time,random

pp = ProxyPool()
pp.start(delay = 10 * 60,ssl = True,debug = True)


def testThread(tid,pp):
	s1 = random.randint(0,40)
	time.sleep(s1)
	proxy = pp.pop(debug=True)
	s2 = random.randint(0,5)
	time.sleep(s2)
	pp.push(proxy,debug=True)

for i in range(0,300):
	threading.Thread(target = testThread,args = (i,pp)).start()

croxxproxypool's People

Contributors

mrcroxx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.